brainclaw 1.9.0 → 1.10.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 +631 -499
- package/dist/brainclaw-vscode.vsix +0 -0
- package/dist/cli.js +18 -1
- package/dist/commands/code-map.js +129 -0
- package/dist/commands/codev.js +7 -0
- package/dist/commands/harvest.js +1 -1
- package/dist/commands/hooks.js +73 -73
- package/dist/commands/init.js +1 -1
- package/dist/commands/install-hooks.js +78 -78
- package/dist/commands/mcp-read-handlers.js +57 -14
- package/dist/commands/mcp.js +200 -13
- package/dist/commands/run-profile.js +3 -2
- package/dist/commands/switch.js +125 -93
- package/dist/commands/version.js +1 -1
- package/dist/core/agent-capability.js +19 -4
- package/dist/core/agent-files.js +131 -119
- package/dist/core/code-map/backend.js +123 -0
- package/dist/core/code-map/core.js +81 -0
- package/dist/core/code-map/drafts.js +2 -0
- package/dist/core/code-map/extractor.js +29 -0
- package/dist/core/code-map/finalizer.js +191 -0
- package/dist/core/code-map/freshness.js +108 -0
- package/dist/core/code-map/ids.js +0 -0
- package/dist/core/code-map/importable.js +35 -0
- package/dist/core/code-map/indexes.js +197 -0
- package/dist/core/code-map/lang/java/imports.scm +17 -0
- package/dist/core/code-map/lang/java/index.js +254 -0
- package/dist/core/code-map/lang/java/tags.scm +48 -0
- package/dist/core/code-map/lang/php/imports.scm +21 -0
- package/dist/core/code-map/lang/php/index.js +251 -0
- package/dist/core/code-map/lang/php/tags.scm +44 -0
- package/dist/core/code-map/lang/provider.js +9 -0
- package/dist/core/code-map/lang/providers.js +24 -0
- package/dist/core/code-map/lang/python/imports.scm +90 -0
- package/dist/core/code-map/lang/python/index.js +364 -0
- package/dist/core/code-map/lang/python/tags.scm +81 -0
- package/dist/core/code-map/lang/query-runtime.js +374 -0
- package/dist/core/code-map/lang/registry.js +125 -0
- package/dist/core/code-map/lang/typescript/imports.scm +90 -0
- package/dist/core/code-map/lang/typescript/index.js +306 -0
- package/dist/core/code-map/lang/typescript/tags.js.scm +106 -0
- package/dist/core/code-map/lang/typescript/tags.scm +151 -0
- package/dist/core/code-map/lock.js +210 -0
- package/dist/core/code-map/materialized.js +51 -0
- package/dist/core/code-map/memory-reader.js +59 -0
- package/dist/core/code-map/paths.js +53 -0
- package/dist/core/code-map/query.js +568 -0
- package/dist/core/code-map/refresh.js +0 -0
- package/dist/core/code-map/resolve.js +177 -0
- package/dist/core/code-map/store.js +206 -0
- package/dist/core/code-map/types.js +288 -0
- package/dist/core/code-map/vocabulary.js +57 -0
- package/dist/core/code-map/wasm-loader.js +294 -0
- package/dist/core/code-map/work-section.js +206 -0
- package/dist/core/codev-prompts.js +38 -38
- package/dist/core/codev-rounds.js +4 -0
- package/dist/core/default-profiles/doctor.yaml +11 -11
- package/dist/core/default-profiles/janitor.yaml +11 -11
- package/dist/core/default-profiles/onboarder.yaml +11 -11
- package/dist/core/default-profiles/reviewer.yaml +13 -13
- package/dist/core/dispatcher.js +1 -1
- package/dist/core/entity-operations.js +29 -3
- package/dist/core/execution-adapters.js +11 -10
- package/dist/core/execution-profile.js +58 -0
- package/dist/core/execution.js +1 -1
- package/dist/core/facade-schema.js +9 -0
- package/dist/core/instruction-templates.js +2 -0
- package/dist/core/loops/verbs.js +0 -1
- package/dist/core/mcp-command-resolution.js +3 -1
- package/dist/core/messaging.js +2 -2
- package/dist/core/protocol-skills.js +164 -164
- package/dist/core/runtime-signals.js +1 -1
- package/dist/core/search.js +19 -2
- package/dist/core/security-guard.js +207 -207
- package/dist/core/spawn-check.js +16 -2
- package/dist/core/staleness.js +1 -1
- package/dist/core/store-resolution.js +67 -11
- package/dist/core/worktree.js +18 -18
- package/dist/facts.js +9 -5
- package/dist/facts.json +8 -4
- package/dist/vendor/web-tree-sitter/tree-sitter.js +3980 -0
- package/dist/vendor/web-tree-sitter/tree-sitter.wasm +0 -0
- package/dist/wasm/tree-sitter-java.wasm +0 -0
- package/dist/wasm/tree-sitter-javascript.wasm +0 -0
- package/dist/wasm/tree-sitter-php.wasm +0 -0
- package/dist/wasm/tree-sitter-python.wasm +0 -0
- package/dist/wasm/tree-sitter-tsx.wasm +0 -0
- package/dist/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/wasm/tree-sitter.wasm +0 -0
- package/docs/PROTOCOL.md +1 -1
- package/docs/adapters/openclaw.md +43 -43
- package/docs/architecture/project-refs.md +328 -328
- package/docs/cli.md +2131 -2093
- package/docs/code-map.md +198 -0
- package/docs/concepts/coordination.md +52 -52
- package/docs/concepts/coordinator-runbook.md +129 -129
- package/docs/concepts/dispatch-lifecycle.md +245 -245
- package/docs/concepts/event-log-store.md +928 -928
- package/docs/concepts/ideation-loop.md +317 -317
- package/docs/concepts/loop-engine.md +520 -511
- package/docs/concepts/mcp-governance.md +268 -268
- package/docs/concepts/memory.md +84 -84
- package/docs/concepts/multi-agent-workflows.md +167 -167
- package/docs/concepts/observer-protocol.md +361 -361
- package/docs/concepts/plans-and-claims.md +217 -217
- package/docs/concepts/project-md-convention.md +35 -35
- package/docs/concepts/runtime-notes.md +38 -38
- package/docs/concepts/troubleshooting.md +254 -254
- package/docs/concepts/workspace-bootstrapping.md +142 -142
- package/docs/context-format-changelog.md +35 -35
- package/docs/context-format.md +48 -48
- package/docs/index.md +65 -65
- package/docs/integrations/agents.md +158 -158
- package/docs/integrations/claude-code.md +23 -23
- package/docs/integrations/cline.md +77 -77
- package/docs/integrations/continue.md +55 -55
- package/docs/integrations/copilot.md +68 -68
- package/docs/integrations/cursor.md +23 -23
- package/docs/integrations/kilocode.md +72 -72
- package/docs/integrations/mcp.md +385 -378
- package/docs/integrations/mistral-vibe.md +122 -122
- package/docs/integrations/openclaw.md +92 -92
- package/docs/integrations/opencode.md +84 -84
- package/docs/integrations/overview.md +115 -115
- package/docs/integrations/roo.md +71 -71
- package/docs/integrations/windsurf.md +77 -77
- package/docs/mcp-schema-changelog.md +364 -356
- package/docs/playbooks/integration/index.md +121 -121
- package/docs/playbooks/orchestration.md +37 -0
- package/docs/playbooks/productivity/index.md +99 -99
- package/docs/playbooks/team/index.md +117 -117
- package/docs/product/agent-first-model.md +184 -184
- package/docs/product/entity-model-audit.md +462 -462
- package/docs/product/positioning.md +86 -86
- package/docs/quickstart-existing-project.md +107 -107
- package/docs/quickstart.md +183 -183
- package/docs/release-maintenance.md +79 -79
- package/docs/reputation.md +52 -52
- package/docs/review.md +45 -45
- package/docs/security.md +212 -212
- package/docs/server-operations.md +118 -118
- package/docs/storage.md +106 -106
- package/package.json +86 -66
- package/docs/concepts/event-log-store-critique-A.md +0 -333
- package/docs/concepts/event-log-store-critique-B.md +0 -353
- package/docs/concepts/event-log-store-phase0-measurements.md +0 -58
- package/docs/concepts/event-log-store-proposal-A.md +0 -365
- package/docs/concepts/event-log-store-proposal-B.md +0 -404
- package/docs/concepts/identity-model-proposal.md +0 -371
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Map langs#3-4 — PhpProvider (provider #3; cadrage v2 §5, dec#113).
|
|
3
|
+
*
|
|
4
|
+
* Owns `.php` (runtime lang `php`). `extractDraft` delegates to the generic
|
|
5
|
+
* query-runtime; the curated `tags.scm`/`imports.scm` (this dir) drive structural
|
|
6
|
+
* extraction. `refine()` carries what the tree-sitter queries CANNOT express
|
|
7
|
+
* (all provider-local, drafts-only):
|
|
8
|
+
* - `__construct` (grammar node `method_declaration`) → subtype `constructor`
|
|
9
|
+
* (Codex R1: PHP has a language-level constructor; collapse into `method` would
|
|
10
|
+
* lose that distinction). Other methods/magic methods stay `method`.
|
|
11
|
+
* - property names: the grammar's `variable_name` node text includes the leading
|
|
12
|
+
* `$` (`$id`); the symbol name is `id` (how the property is referenced) → strip.
|
|
13
|
+
* - GROUP use (`use A\{B, C as Bee}`): the query captures each clause's leaf name
|
|
14
|
+
* (`B`, `C`) because NO single tree node carries the full `A\B` (Codex R1). We
|
|
15
|
+
* walk the retained tree, find each group-use statement's prefix (`A`), and
|
|
16
|
+
* prepend it to the leaf-name import drafts at that statement's span → full
|
|
17
|
+
* source paths `A\B`, `A\C` (aliases already dropped by the query).
|
|
18
|
+
*
|
|
19
|
+
* NO exports edges — PHP `use` is modeled as module imports; there is no export
|
|
20
|
+
* statement (capabilities: T2 = imports).
|
|
21
|
+
*
|
|
22
|
+
* Identity is owned by the CORE finalizer — this provider mints NO ids. The grammar
|
|
23
|
+
* is loaded through the SHARED engine glue (`loadGrammarWasm`), NEVER a fresh
|
|
24
|
+
* `web-tree-sitter` import (trp_8df65ab7).
|
|
25
|
+
*/
|
|
26
|
+
import crypto from 'node:crypto';
|
|
27
|
+
import fs from 'node:fs';
|
|
28
|
+
import path from 'node:path';
|
|
29
|
+
import { fileURLToPath } from 'node:url';
|
|
30
|
+
import { loadGrammarWasm, grammarHashForWasm } from '../../wasm-loader.js';
|
|
31
|
+
import { extractWithQueries } from '../query-runtime.js';
|
|
32
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
/** The php grammar .wasm: dist basename + node_modules devDep fallback spec. */
|
|
34
|
+
const PHP_WASM_BASENAME = 'tree-sitter-php.wasm';
|
|
35
|
+
const PHP_WASM_NODE_MODULES_SPEC = 'tree-sitter-wasms/out/tree-sitter-php.wasm';
|
|
36
|
+
const PHP_GRAMMAR_NAME = 'tree-sitter-php';
|
|
37
|
+
/** Resolve a vendored `.scm` next to this module (dist) or from the source tree. */
|
|
38
|
+
function readScm(basename) {
|
|
39
|
+
// Published / dist runtime: this module is dist/core/code-map/lang/php/index.js
|
|
40
|
+
// and the build copies the .scm assets alongside it (copy-code-map-wasm.mjs).
|
|
41
|
+
const local = path.join(HERE, basename);
|
|
42
|
+
if (fs.existsSync(local))
|
|
43
|
+
return fs.readFileSync(local, 'utf-8');
|
|
44
|
+
// From-source / dist-test fallback: tsc emits to dist[-test]/... but does NOT copy
|
|
45
|
+
// .scm, so walk up to the repo root (the dir holding package.json) and read the
|
|
46
|
+
// curated asset from src/core/code-map/lang/php/.
|
|
47
|
+
let dir = HERE;
|
|
48
|
+
for (let i = 0; i < 12; i++) {
|
|
49
|
+
if (fs.existsSync(path.join(dir, 'package.json'))) {
|
|
50
|
+
const fromSrc = path.join(dir, 'src', 'core', 'code-map', 'lang', 'php', basename);
|
|
51
|
+
if (fs.existsSync(fromSrc))
|
|
52
|
+
return fs.readFileSync(fromSrc, 'utf-8');
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const parent = path.dirname(dir);
|
|
56
|
+
if (parent === dir)
|
|
57
|
+
break;
|
|
58
|
+
dir = parent;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`code-map: could not locate query asset ${basename} (from ${HERE})`);
|
|
61
|
+
}
|
|
62
|
+
function sha256(s) {
|
|
63
|
+
return `sha256:${crypto.createHash('sha256').update(s, 'utf-8').digest('hex')}`;
|
|
64
|
+
}
|
|
65
|
+
// Load the curated query assets once at module init.
|
|
66
|
+
const TAGS = readScm('tags.scm');
|
|
67
|
+
const IMPORTS = readScm('imports.scm');
|
|
68
|
+
const TAGS_HASH = sha256(TAGS);
|
|
69
|
+
const IMPORTS_HASH = sha256(IMPORTS);
|
|
70
|
+
const parser = {
|
|
71
|
+
grammarForLang: () => loadGrammarWasm(PHP_WASM_BASENAME, PHP_WASM_NODE_MODULES_SPEC),
|
|
72
|
+
grammarNameForLang: () => PHP_GRAMMAR_NAME,
|
|
73
|
+
grammarHashForLang: () => grammarHashForWasm(PHP_WASM_BASENAME, PHP_WASM_NODE_MODULES_SPEC),
|
|
74
|
+
};
|
|
75
|
+
const queries = {
|
|
76
|
+
tags: {
|
|
77
|
+
name: 'tags',
|
|
78
|
+
sourceForLang: () => TAGS,
|
|
79
|
+
hashForLang: () => TAGS_HASH,
|
|
80
|
+
},
|
|
81
|
+
imports: {
|
|
82
|
+
name: 'imports',
|
|
83
|
+
sourceForLang: () => IMPORTS,
|
|
84
|
+
hashForLang: () => IMPORTS_HASH,
|
|
85
|
+
},
|
|
86
|
+
// PHP `use` declarations are the import statement; PHP has no export statement.
|
|
87
|
+
enclosingStatementNodeTypes: ['namespace_use_declaration'],
|
|
88
|
+
// P1b §3.4 / cadrage: every capture mirrors the hard-coded runtime convention and
|
|
89
|
+
// is validated by `assertCaptureMapConforms`. PHP invents none beyond the
|
|
90
|
+
// namespaced `php.trait` subtype (still a definition.<subtype>.* capture).
|
|
91
|
+
captureMap: [
|
|
92
|
+
{ capture: 'definition.namespace.node', field: 'node', subtype: 'namespace' },
|
|
93
|
+
{ capture: 'definition.namespace.name', field: 'name' },
|
|
94
|
+
{ capture: 'definition.class.node', field: 'node', subtype: 'class' },
|
|
95
|
+
{ capture: 'definition.class.name', field: 'name' },
|
|
96
|
+
{ capture: 'definition.interface.node', field: 'node', subtype: 'interface' },
|
|
97
|
+
{ capture: 'definition.interface.name', field: 'name' },
|
|
98
|
+
{ capture: 'definition.php.trait.node', field: 'node', subtype: 'php.trait' },
|
|
99
|
+
{ capture: 'definition.php.trait.name', field: 'name' },
|
|
100
|
+
{ capture: 'definition.enum.node', field: 'node', subtype: 'enum' },
|
|
101
|
+
{ capture: 'definition.enum.name', field: 'name' },
|
|
102
|
+
{ capture: 'definition.function.node', field: 'node', subtype: 'function' },
|
|
103
|
+
{ capture: 'definition.function.name', field: 'name' },
|
|
104
|
+
{ capture: 'definition.method.node', field: 'node', subtype: 'method' },
|
|
105
|
+
{ capture: 'definition.method.name', field: 'name' },
|
|
106
|
+
{ capture: 'definition.constant.node', field: 'node', subtype: 'constant' },
|
|
107
|
+
{ capture: 'definition.constant.name', field: 'name' },
|
|
108
|
+
{ capture: 'definition.property.node', field: 'node', subtype: 'property' },
|
|
109
|
+
{ capture: 'definition.property.name', field: 'name' },
|
|
110
|
+
{ capture: 'import.source', field: 'source' },
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
const vocabulary = {
|
|
114
|
+
nodeSubtypes: [
|
|
115
|
+
'namespace',
|
|
116
|
+
'class',
|
|
117
|
+
'interface',
|
|
118
|
+
'php.trait',
|
|
119
|
+
'enum',
|
|
120
|
+
'function',
|
|
121
|
+
'method',
|
|
122
|
+
'constructor',
|
|
123
|
+
'constant',
|
|
124
|
+
'property',
|
|
125
|
+
],
|
|
126
|
+
edgeKinds: ['contains', 'defines', 'imports'],
|
|
127
|
+
captureMap: queries.captureMap,
|
|
128
|
+
};
|
|
129
|
+
const capabilities = {
|
|
130
|
+
tiers: ['T1.definitions', 'T2.imports'],
|
|
131
|
+
proven: {
|
|
132
|
+
'T1.definitions': true,
|
|
133
|
+
'T2.imports': true,
|
|
134
|
+
'T3.import_resolution': false,
|
|
135
|
+
'T4.tests_for': false,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
/** Build a span key matching the runtime's `spanOf` (1-based start/end line+col). */
|
|
139
|
+
function spanKeyOfNode(node) {
|
|
140
|
+
return `${node.startPosition.row + 1}:${node.startPosition.column + 1}:${node.endPosition.row + 1}:${node.endPosition.column + 1}`;
|
|
141
|
+
}
|
|
142
|
+
/** Iterative named-node DFS collecting nodes whose type is in `types`. */
|
|
143
|
+
function collectByType(root, types) {
|
|
144
|
+
const found = [];
|
|
145
|
+
const stack = [root];
|
|
146
|
+
while (stack.length > 0) {
|
|
147
|
+
const n = stack.pop();
|
|
148
|
+
if (types.has(n.type))
|
|
149
|
+
found.push(n);
|
|
150
|
+
for (let i = 0; i < n.namedChildCount; i++) {
|
|
151
|
+
const c = n.namedChild(i);
|
|
152
|
+
if (c)
|
|
153
|
+
stack.push(c);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return found;
|
|
157
|
+
}
|
|
158
|
+
const USE_DECL = new Set(['namespace_use_declaration']);
|
|
159
|
+
/**
|
|
160
|
+
* For each GROUP use statement (a `namespace_use_declaration` that contains a
|
|
161
|
+
* `namespace_use_group`), map its statement span → the group PREFIX (the direct
|
|
162
|
+
* `namespace_name` child, e.g. `App\Util`). The runtime emitted one import draft
|
|
163
|
+
* per group leaf (sources are the bare leaf names) at that statement's span;
|
|
164
|
+
* refine prepends `prefix\` to each.
|
|
165
|
+
*/
|
|
166
|
+
function groupPrefixBySpan(tree) {
|
|
167
|
+
const out = new Map();
|
|
168
|
+
for (const decl of collectByType(tree.rootNode, USE_DECL)) {
|
|
169
|
+
let group = null;
|
|
170
|
+
let prefix = null;
|
|
171
|
+
for (let i = 0; i < decl.namedChildCount; i++) {
|
|
172
|
+
const c = decl.namedChild(i);
|
|
173
|
+
if (!c)
|
|
174
|
+
continue;
|
|
175
|
+
if (c.type === 'namespace_use_group')
|
|
176
|
+
group = c;
|
|
177
|
+
else if (c.type === 'namespace_name' && !prefix)
|
|
178
|
+
prefix = c;
|
|
179
|
+
}
|
|
180
|
+
if (group && prefix)
|
|
181
|
+
out.set(spanKeyOfNode(decl), prefix.text);
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
export class PhpProvider {
|
|
186
|
+
id = 'php';
|
|
187
|
+
displayName = 'PHP';
|
|
188
|
+
languages = ['php'];
|
|
189
|
+
extensions = ['.php'];
|
|
190
|
+
priority = 0;
|
|
191
|
+
version = '0.1.0';
|
|
192
|
+
parser = parser;
|
|
193
|
+
queries = queries;
|
|
194
|
+
vocabulary = vocabulary;
|
|
195
|
+
capabilities = capabilities;
|
|
196
|
+
/** `.php` → `php`. */
|
|
197
|
+
langForPath(_p) {
|
|
198
|
+
return 'php';
|
|
199
|
+
}
|
|
200
|
+
async extractDraft(input, _services) {
|
|
201
|
+
return extractWithQueries({
|
|
202
|
+
providerId: this.id,
|
|
203
|
+
lang: input.lang,
|
|
204
|
+
source: input.source,
|
|
205
|
+
sizeBytes: input.sizeBytes,
|
|
206
|
+
maxParseFileBytes: input.maxParseFileBytes,
|
|
207
|
+
maxQueryWaitMs: input.maxQueryWaitMs,
|
|
208
|
+
path: input.path,
|
|
209
|
+
grammarForLang: this.parser.grammarForLang,
|
|
210
|
+
tagsSource: TAGS,
|
|
211
|
+
tagsHash: TAGS_HASH,
|
|
212
|
+
importsSource: IMPORTS,
|
|
213
|
+
importsHash: IMPORTS_HASH,
|
|
214
|
+
enclosingStatementNodeTypes: queries.enclosingStatementNodeTypes,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Drafts-only refinement (cadrage v2 §5):
|
|
219
|
+
* - definitions: `__construct` method → constructor; property name `$x` → `x`.
|
|
220
|
+
* - imports: synthesize full group-use source paths by prepending the prefix.
|
|
221
|
+
*/
|
|
222
|
+
refine(draft, _ctx) {
|
|
223
|
+
const definitions = draft.definitions.map((d) => {
|
|
224
|
+
if (d.subtype === 'method' && d.name === '__construct') {
|
|
225
|
+
return { ...d, subtype: 'constructor' };
|
|
226
|
+
}
|
|
227
|
+
if (d.subtype === 'property' && d.name.startsWith('$')) {
|
|
228
|
+
return { ...d, name: d.name.slice(1) };
|
|
229
|
+
}
|
|
230
|
+
return d;
|
|
231
|
+
});
|
|
232
|
+
let imports = draft.imports;
|
|
233
|
+
const tree = draft.attributes?.__tree;
|
|
234
|
+
if (tree) {
|
|
235
|
+
const prefixBySpan = groupPrefixBySpan(tree);
|
|
236
|
+
if (prefixBySpan.size > 0) {
|
|
237
|
+
imports = draft.imports.map((im) => {
|
|
238
|
+
const key = `${im.span.start_line}:${im.span.start_col}:${im.span.end_line}:${im.span.end_col}`;
|
|
239
|
+
const prefix = prefixBySpan.get(key);
|
|
240
|
+
// A group statement only ever produced group-leaf imports at its span;
|
|
241
|
+
// a comma/simple `use` is a different statement (different span).
|
|
242
|
+
return prefix ? { ...im, source: `${prefix}\\${im.source}` } : im;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return { ...draft, definitions, imports };
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Singleton instance for registry wiring. */
|
|
250
|
+
export const phpProvider = new PhpProvider();
|
|
251
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
; Code Map — PHP definitions (tags.scm). Provider #3 (langs#3-4).
|
|
2
|
+
;
|
|
3
|
+
; Capture-name convention (query-runtime.ts is the contract):
|
|
4
|
+
; @definition.<subtype>.node = the identity-span anchor (the whole declaration)
|
|
5
|
+
; @definition.<subtype>.name = the symbol name node
|
|
6
|
+
; Subtypes: namespace/class/interface/enum/function/method/constant/property are
|
|
7
|
+
; universal; php.trait is namespaced (a trait is NOT substitutable for an
|
|
8
|
+
; interface). __construct is captured as `method` here and reclassified to
|
|
9
|
+
; `constructor` in the provider's refine() (the grammar node is method_declaration).
|
|
10
|
+
; enum cases and class consts both map to `constant`.
|
|
11
|
+
|
|
12
|
+
(namespace_definition
|
|
13
|
+
name: (namespace_name) @definition.namespace.name) @definition.namespace.node
|
|
14
|
+
|
|
15
|
+
(class_declaration
|
|
16
|
+
name: (name) @definition.class.name) @definition.class.node
|
|
17
|
+
|
|
18
|
+
(interface_declaration
|
|
19
|
+
name: (name) @definition.interface.name) @definition.interface.node
|
|
20
|
+
|
|
21
|
+
(trait_declaration
|
|
22
|
+
name: (name) @definition.php.trait.name) @definition.php.trait.node
|
|
23
|
+
|
|
24
|
+
(enum_declaration
|
|
25
|
+
name: (name) @definition.enum.name) @definition.enum.node
|
|
26
|
+
|
|
27
|
+
(enum_case
|
|
28
|
+
name: (name) @definition.constant.name) @definition.constant.node
|
|
29
|
+
|
|
30
|
+
(function_definition
|
|
31
|
+
name: (name) @definition.function.name) @definition.function.node
|
|
32
|
+
|
|
33
|
+
(method_declaration
|
|
34
|
+
name: (name) @definition.method.name) @definition.method.node
|
|
35
|
+
|
|
36
|
+
; `const A = 1, B = 2;` yields one match per const_element (all sharing the
|
|
37
|
+
; const_declaration identity span) — mirrors the JS/TS `const a,b` shared-span rule.
|
|
38
|
+
(const_declaration
|
|
39
|
+
(const_element (name) @definition.constant.name)) @definition.constant.node
|
|
40
|
+
|
|
41
|
+
; `public int $a, $b;` yields one match per property_element. The name node is the
|
|
42
|
+
; `variable_name` (text "$a"); refine() strips the leading `$` for the symbol name.
|
|
43
|
+
(property_declaration
|
|
44
|
+
(property_element (variable_name) @definition.property.name)) @definition.property.node
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default {@link CodeLanguageProvider.isImportableSymbol}: a real, externally
|
|
3
|
+
* importable definition. Excludes synthetic `subtype:'export'` placeholders (TS
|
|
4
|
+
* export-clause nodes) so B never binds to a non-definition (Codex cadrage review).
|
|
5
|
+
*/
|
|
6
|
+
export function defaultImportableSymbol(node) {
|
|
7
|
+
return node.kind === 'symbol' && node.exported === true && node.subtype !== 'export';
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Map — default provider REGISTRATION list (P1b §3.2).
|
|
3
|
+
*
|
|
4
|
+
* This is the single declared EXTENSION POINT for "which language providers ship
|
|
5
|
+
* by default". Adding a language = importing its provider here and adding it to
|
|
6
|
+
* the `createRegistry(...)` call below — NOT editing `core.ts` (the orchestration)
|
|
7
|
+
* or the registry mechanics. `core.ts` imports the constructed `defaultRegistry`
|
|
8
|
+
* from this module.
|
|
9
|
+
*
|
|
10
|
+
* Registration order is the secondary collision tiebreak (after `priority`); keep
|
|
11
|
+
* it intentional. Pure construction — no behavior change vs the P1a inline
|
|
12
|
+
* `createRegistry(typeScriptProvider)` that previously lived in `core.ts`.
|
|
13
|
+
*/
|
|
14
|
+
import { createRegistry } from './registry.js';
|
|
15
|
+
import { typeScriptProvider } from './typescript/index.js';
|
|
16
|
+
import { pythonProvider } from './python/index.js';
|
|
17
|
+
import { phpProvider } from './php/index.js';
|
|
18
|
+
import { javaProvider } from './java/index.js';
|
|
19
|
+
/**
|
|
20
|
+
* The default registry, pre-loaded with the bundled providers. Add a new
|
|
21
|
+
* provider's singleton to this `createRegistry(...)` call to register it.
|
|
22
|
+
*/
|
|
23
|
+
export const defaultRegistry = createRegistry(typeScriptProvider, pythonProvider, phpProvider, javaProvider);
|
|
24
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
; Brainclaw Code Map — Python IMPORTS query (curated, vendored).
|
|
2
|
+
; Grammar: tree-sitter-python. See ./README.md for the capture-name convention.
|
|
3
|
+
;
|
|
4
|
+
; Python has NO export statement, so this asset emits imports ONLY (no @export.name).
|
|
5
|
+
; Capabilities declare T2.imports = complete (specifiers); resolution is P1c.
|
|
6
|
+
;
|
|
7
|
+
; Capture -> draft mapping performed by the generic query-runtime:
|
|
8
|
+
; @import.source -> ImportDraft.source (the runtime strips surrounding quotes;
|
|
9
|
+
; Python module names are bare identifiers/dotted_names, so
|
|
10
|
+
; there is nothing to strip — the text passes through verbatim,
|
|
11
|
+
; which is exactly what relative-import dots `.` / `..pkg`
|
|
12
|
+
; need). ALSO anchors ImportDraft.span = enclosing
|
|
13
|
+
; import_statement / import_from_statement.
|
|
14
|
+
; @import.named.name -> a source-side imported name (the `from x import NAME` target,
|
|
15
|
+
; NOT the local alias; `*` for a wildcard import)
|
|
16
|
+
; @import.default.name -> (unused for Python — no default-import concept)
|
|
17
|
+
; @import.namespace.name -> (unused for Python — `import x as y` is a source-side
|
|
18
|
+
; module node, not a namespace specifier)
|
|
19
|
+
;
|
|
20
|
+
; MULTI-SOURCE awareness (spec §3.3 / §6): the runtime groups module nodes PER captured
|
|
21
|
+
; @import.source NODE, not per enclosing statement. So `import a, b` — one statement with
|
|
22
|
+
; two `name:` children — yields TWO @import.source captures and therefore TWO module
|
|
23
|
+
; nodes. For a `from x import a, b` statement the single module_name source node is
|
|
24
|
+
; captured once per imported `name:` child across N matches; the runtime accumulates all
|
|
25
|
+
; the names onto the one source node (keyed by node id). The span/ordinal stay anchored
|
|
26
|
+
; on the enclosing statement.
|
|
27
|
+
|
|
28
|
+
; ===========================================================================
|
|
29
|
+
; `import` STATEMENTS (import x / import x.y / import a, b / import x as y)
|
|
30
|
+
; ===========================================================================
|
|
31
|
+
|
|
32
|
+
; import x / import x.y / import a, b
|
|
33
|
+
; Each `name:` child that is a bare dotted_name is one module source. A multi-source
|
|
34
|
+
; statement (`import a, b`) has multiple `name:` children => multiple matches =>
|
|
35
|
+
; multiple @import.source captures => multiple module nodes.
|
|
36
|
+
(import_statement
|
|
37
|
+
name: (dotted_name) @import.source)
|
|
38
|
+
|
|
39
|
+
; import x as y -> source-side module is `x`; the alias `y` is ignored (imported
|
|
40
|
+
; names are source-side). Capture the INNER dotted_name only (NOT the aliased_import).
|
|
41
|
+
(import_statement
|
|
42
|
+
name: (aliased_import
|
|
43
|
+
name: (dotted_name) @import.source))
|
|
44
|
+
|
|
45
|
+
; ===========================================================================
|
|
46
|
+
; `from … import …` STATEMENTS
|
|
47
|
+
; ===========================================================================
|
|
48
|
+
|
|
49
|
+
; from x import a / from x.y import a, b
|
|
50
|
+
; One match per imported `name:` child; all share the single module_name source node,
|
|
51
|
+
; so the runtime accumulates a, b onto module `x` (grouped by source-node id).
|
|
52
|
+
(import_from_statement
|
|
53
|
+
module_name: (dotted_name) @import.source
|
|
54
|
+
name: (dotted_name) @import.named.name)
|
|
55
|
+
|
|
56
|
+
; from x import a as c -> source-side imported name is `a` (alias `c` ignored).
|
|
57
|
+
(import_from_statement
|
|
58
|
+
module_name: (dotted_name) @import.source
|
|
59
|
+
name: (aliased_import
|
|
60
|
+
name: (dotted_name) @import.named.name))
|
|
61
|
+
|
|
62
|
+
; from x import * -> the wildcard_import node's text is `*`, captured as the name.
|
|
63
|
+
(import_from_statement
|
|
64
|
+
module_name: (dotted_name) @import.source
|
|
65
|
+
(wildcard_import) @import.named.name)
|
|
66
|
+
|
|
67
|
+
; ===========================================================================
|
|
68
|
+
; RELATIVE `from … import …` (from . import z / from ..pkg import a, b / *)
|
|
69
|
+
;
|
|
70
|
+
; The relative_import node's TEXT is the verbatim specifier WITH its leading dots
|
|
71
|
+
; (`.`, `..`, `..pkg`) — that text IS how the relative-import level survives without a
|
|
72
|
+
; durable-attribute field (spec §6); P1c resolution consumes the dots. Capturing the
|
|
73
|
+
; relative_import node directly as @import.source preserves it verbatim.
|
|
74
|
+
; ===========================================================================
|
|
75
|
+
|
|
76
|
+
; from . import z / from ..pkg import a, b
|
|
77
|
+
(import_from_statement
|
|
78
|
+
module_name: (relative_import) @import.source
|
|
79
|
+
name: (dotted_name) @import.named.name)
|
|
80
|
+
|
|
81
|
+
; from .pkg import a as c
|
|
82
|
+
(import_from_statement
|
|
83
|
+
module_name: (relative_import) @import.source
|
|
84
|
+
name: (aliased_import
|
|
85
|
+
name: (dotted_name) @import.named.name))
|
|
86
|
+
|
|
87
|
+
; from . import *
|
|
88
|
+
(import_from_statement
|
|
89
|
+
module_name: (relative_import) @import.source
|
|
90
|
+
(wildcard_import) @import.named.name)
|