chain-insights 0.2.18 → 0.2.21
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 +54 -12
- package/bin/cli.js +2 -3
- package/bin/install.cjs +0 -1
- package/dist/{app-DxlQE_P5.cjs → app-BxojXjtB.cjs} +1 -1
- package/dist/{app-DdWQF_zb.mjs → app-CRd39JJ8.mjs} +2 -2
- package/dist/{app-DdWQF_zb.mjs.map → app-CRd39JJ8.mjs.map} +1 -1
- package/dist/{artifact-server-4DiMvwhC.mjs → artifact-server-CP6LXQ9d.mjs} +2 -2
- package/dist/{artifact-server-4DiMvwhC.mjs.map → artifact-server-CP6LXQ9d.mjs.map} +1 -1
- package/dist/{artifact-server-B-3ho4bk.cjs → artifact-server-XbN16DwU.cjs} +1 -1
- package/dist/cli.cjs +66 -25
- package/dist/cli.mjs +66 -25
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-BhYbhLDI.cjs → config-BwVx19Og.cjs} +48 -15
- package/dist/config-Drgc2HuF.mjs +77 -0
- package/dist/config-Drgc2HuF.mjs.map +1 -0
- package/dist/frontmatter-D0ccQnUM.mjs.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/{init-CZbZegIW.mjs → init-4tn7jfhN.mjs} +3 -2
- package/dist/init-4tn7jfhN.mjs.map +1 -0
- package/dist/{init-BvpZtFiT.cjs → init-TCQY5RDJ.cjs} +2 -1
- package/dist/mcp-endpoint-BaV8h_lq.cjs +60 -0
- package/dist/mcp-endpoint-DHs1cRFH.mjs +39 -0
- package/dist/mcp-endpoint-DHs1cRFH.mjs.map +1 -0
- package/dist/mcp-proxy.cjs +108 -9
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +108 -9
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{public-tools-D6Q5MTcO.mjs → public-tools-B13J0MJZ.mjs} +465 -70
- package/dist/public-tools-B13J0MJZ.mjs.map +1 -0
- package/dist/{public-tools-V7ON7goq.cjs → public-tools-BC1fi0DV.cjs} +464 -68
- package/dist/resolver-D7VBb0uB.mjs.map +1 -1
- package/dist/{runner-BatyCxv7.mjs → runner-DIs04IhN.mjs} +2 -2
- package/dist/{runner-BatyCxv7.mjs.map → runner-DIs04IhN.mjs.map} +1 -1
- package/dist/{runner-CCA7SJ7X.cjs → runner-ZYowxCVl.cjs} +1 -1
- package/dist/schema-BFEWhzg7.mjs +60 -0
- package/dist/schema-BFEWhzg7.mjs.map +1 -0
- package/dist/{schema-DN-KLkYN.cjs → schema-Vl9yuOFO.cjs} +31 -8
- package/dist/{server-BDlbmGbL.mjs → server-BXLX2j_A.mjs} +2 -2
- package/dist/{server-BDlbmGbL.mjs.map → server-BXLX2j_A.mjs.map} +1 -1
- package/dist/{server-C3y1gQmZ.cjs → server-BqVdWath.cjs} +1 -1
- package/dist/{topup-server-6MH7q73X.mjs → topup-server-BJgVw6Jt.mjs} +100 -42
- package/dist/topup-server-BJgVw6Jt.mjs.map +1 -0
- package/dist/{topup-server-DjUjhNjv.cjs → topup-server-yAaXYkJP.cjs} +98 -40
- package/docs/architecture.md +4 -0
- package/docs/contributing.md +1 -0
- package/docs/debugging.md +10 -14
- package/docs/graph-tools.md +60 -2
- package/docs/mcp-proxy.md +44 -0
- package/package.json +2 -2
- package/skills/chain-insights-developer-experience/SKILL.md +4 -2
- package/skills/chain-insights-investigation/SKILL.md +1 -1
- package/skills/test-chain-insights-graphrag-mcp/SKILL.md +4 -5
- package/skills/test-chain-insights-graphrag-mcp/scripts/run-uat.sh +5 -24
- package/dist/config-9KYXaAv-.mjs +0 -44
- package/dist/config-9KYXaAv-.mjs.map +0 -1
- package/dist/init-CZbZegIW.mjs.map +0 -1
- package/dist/public-tools-D6Q5MTcO.mjs.map +0 -1
- package/dist/schema-BbQVXp36.mjs +0 -37
- package/dist/schema-BbQVXp36.mjs.map +0 -1
- package/dist/topup-server-6MH7q73X.mjs.map +0 -1
|
@@ -46,7 +46,7 @@ cia debug off
|
|
|
46
46
|
address activity, or requested chain falls outside that range, state that
|
|
47
47
|
limitation before querying. Do not call `address_risk` unless the selected
|
|
48
48
|
network advertises risk support and `address_risk` is available. If only
|
|
49
|
-
topology is available, use `track_funds`, `scam_topology`, or
|
|
49
|
+
topology is available, use `stake_insights`, `track_funds`, `scam_topology`, or
|
|
50
50
|
`graph_query_batch` with `USE live_topology` as appropriate. Use
|
|
51
51
|
`graph_query_batch` with `USE archive_topology`
|
|
52
52
|
for historical money-flow topology, and `USE facts`
|
|
@@ -17,12 +17,13 @@ skills/test-chain-insights-graphrag-mcp/scripts/run-uat.sh
|
|
|
17
17
|
The script writes raw MCP responses and a summary under `chain-insights/.tmp/uat/`.
|
|
18
18
|
It creates and uses a temporary initialized Chain Insights workspace for all
|
|
19
19
|
investigation-producing commands.
|
|
20
|
+
|
|
21
|
+
Before running it, start or configure a GraphRAG MCP endpoint that accepts the
|
|
22
|
+
debug bearer token used by the script.
|
|
20
23
|
</quick_start>
|
|
21
24
|
|
|
22
25
|
<defaults>
|
|
23
|
-
- Chain Insights repo:
|
|
24
|
-
- GraphRAG compose root: `/home/aphex5/work/rbmk/repos/ml`
|
|
25
|
-
- GraphRAG repo: `/home/aphex5/work/rbmk/repos/ml/graphrag`
|
|
26
|
+
- Chain Insights repo: auto-detected from this package checkout
|
|
26
27
|
- MCP endpoint: `http://localhost:8012/mcp`
|
|
27
28
|
- Debug bearer token: `chain-insights-dev-debug`
|
|
28
29
|
- Chain Insights local server port: `4321`
|
|
@@ -34,8 +35,6 @@ Override defaults with environment variables:
|
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
37
|
CHAIN_INSIGHTS_DIR=/path/to/chain-insights \
|
|
37
|
-
GRAPHRAG_ML_DIR=/path/to/rbmk/repos/ml \
|
|
38
|
-
GRAPHRAG_DIR=/path/to/rbmk/repos/ml/graphrag \
|
|
39
38
|
GRAPHRAG_MCP_ENDPOINT=http://localhost:8012/mcp \
|
|
40
39
|
GRAPHRAG_DEBUG_TOKEN=chain-insights-dev-debug \
|
|
41
40
|
CHAIN_INSIGHTS_SERVER_PORT=4321 \
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -Eeuo pipefail
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
GRAPHRAG_DIR="${GRAPHRAG_DIR:-${GRAPHRAG_ML_DIR}/graphrag}"
|
|
7
|
-
RBMK_DIR="${RBMK_DIR:-$(cd "${GRAPHRAG_ML_DIR}/../.." && pwd)}"
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
CHAIN_INSIGHTS_DIR="${CHAIN_INSIGHTS_DIR:-$(cd "${SCRIPT_DIR}/../../.." && pwd)}"
|
|
8
6
|
MCP_ENDPOINT="${GRAPHRAG_MCP_ENDPOINT:-http://localhost:8012/mcp}"
|
|
9
7
|
DEBUG_TOKEN="${GRAPHRAG_DEBUG_TOKEN:-chain-insights-dev-debug}"
|
|
10
8
|
SERVER_PORT="${CHAIN_INSIGHTS_SERVER_PORT:-4321}"
|
|
@@ -105,7 +103,6 @@ trap finish EXIT
|
|
|
105
103
|
require_cmd node
|
|
106
104
|
require_cmd npm
|
|
107
105
|
require_cmd npx
|
|
108
|
-
require_cmd docker
|
|
109
106
|
require_cmd curl
|
|
110
107
|
require_cmd sha256sum
|
|
111
108
|
|
|
@@ -114,21 +111,6 @@ if [[ ! -d "${CHAIN_INSIGHTS_DIR}" ]]; then
|
|
|
114
111
|
exit 1
|
|
115
112
|
fi
|
|
116
113
|
|
|
117
|
-
if [[ ! -d "${GRAPHRAG_ML_DIR}" ]]; then
|
|
118
|
-
log "missing GraphRAG compose root: ${GRAPHRAG_ML_DIR}"
|
|
119
|
-
exit 1
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
|
-
if [[ ! -d "${RBMK_DIR}" ]]; then
|
|
123
|
-
log "missing RBMK dev stack root: ${RBMK_DIR}"
|
|
124
|
-
exit 1
|
|
125
|
-
fi
|
|
126
|
-
|
|
127
|
-
if [[ ! -d "${GRAPHRAG_DIR}" ]]; then
|
|
128
|
-
log "missing GraphRAG repo: ${GRAPHRAG_DIR}"
|
|
129
|
-
exit 1
|
|
130
|
-
fi
|
|
131
|
-
|
|
132
114
|
log "report directory: ${RUN_DIR}"
|
|
133
115
|
snapshot_global_outputs "${GLOBAL_SNAPSHOT_BEFORE}"
|
|
134
116
|
OLD_GRAPH_MCP_MODE="$(node "${CHAIN_INSIGHTS_CLI}" config get graphMcpMode || true)"
|
|
@@ -136,8 +118,7 @@ OLD_GRAPH_MCP_ENDPOINT="$(node "${CHAIN_INSIGHTS_CLI}" config get graphMcpEndpoi
|
|
|
136
118
|
OLD_GRAPH_MCP_AUTH_TOKEN="$(node "${CHAIN_INSIGHTS_CLI}" config get graphMcpAuthToken || true)"
|
|
137
119
|
OLD_SERVER_PORT="$(node "${CHAIN_INSIGHTS_CLI}" config get serverPort || true)"
|
|
138
120
|
CONFIG_SNAPSHOT_READY=1
|
|
139
|
-
log "
|
|
140
|
-
(cd "${RBMK_DIR}" && bash dev.sh --bg)
|
|
121
|
+
log "using GraphRAG MCP endpoint: ${MCP_ENDPOINT}"
|
|
141
122
|
|
|
142
123
|
cd "${CHAIN_INSIGHTS_DIR}"
|
|
143
124
|
|
|
@@ -263,7 +244,7 @@ const file = process.argv[2]
|
|
|
263
244
|
const data = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
264
245
|
const tools = data.tools || []
|
|
265
246
|
const names = new Set(tools.map((tool) => tool.name))
|
|
266
|
-
const required = ['balance', 'help', 'address_risk', 'track_funds', 'scam_topology', 'network_capabilities', 'graph_query', 'graph_query_batch']
|
|
247
|
+
const required = ['balance', 'help', 'address_risk', 'stake_insights', 'track_funds', 'scam_topology', 'network_capabilities', 'graph_query', 'graph_query_batch']
|
|
267
248
|
const missing = required.filter((name) => !names.has(name))
|
|
268
249
|
if (missing.length) throw new Error(`proxy tools/list missing tools: ${missing.join(', ')}`)
|
|
269
250
|
for (const hidden of ['topup', 'trace_funds', 'money_flows_between_exchanges', 'address_connection_risk']) {
|
|
@@ -271,7 +252,7 @@ for (const hidden of ['topup', 'trace_funds', 'money_flows_between_exchanges', '
|
|
|
271
252
|
}
|
|
272
253
|
if (JSON.stringify(tools).includes('app_data')) throw new Error('proxy tools/list still contains app_data')
|
|
273
254
|
const graphTools = tools.filter((tool) => tool._meta?.ui?.resourceUri === 'ui://chain-insights/graph').map((tool) => tool.name)
|
|
274
|
-
for (const name of ['address_risk', 'track_funds', 'scam_topology']) {
|
|
255
|
+
for (const name of ['address_risk', 'stake_insights', 'track_funds', 'scam_topology']) {
|
|
275
256
|
if (!graphTools.includes(name)) throw new Error(`proxy graph app metadata missing for ${name}`)
|
|
276
257
|
}
|
|
277
258
|
console.log(`[uat] proxy tools/list ok: ${tools.length} tools`)
|
package/dist/config-9KYXaAv-.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { n as DEFAULT_CONFIG, t as ConfigSchema } from "./schema-BbQVXp36.mjs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
|
-
import os from "node:os";
|
|
6
|
-
//#region src/config/index.ts
|
|
7
|
-
var config_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
loadConfig: () => loadConfig,
|
|
9
|
-
resetConfigCache: () => resetConfigCache,
|
|
10
|
-
saveConfig: () => saveConfig
|
|
11
|
-
});
|
|
12
|
-
function configPath() {
|
|
13
|
-
return path.join(os.homedir(), ".chain-insights", "config.json");
|
|
14
|
-
}
|
|
15
|
-
let _cached = null;
|
|
16
|
-
async function loadConfig() {
|
|
17
|
-
if (_cached) return _cached;
|
|
18
|
-
try {
|
|
19
|
-
const raw = await readFile(configPath(), "utf8");
|
|
20
|
-
const parsed = JSON.parse(raw);
|
|
21
|
-
_cached = ConfigSchema.parse(parsed);
|
|
22
|
-
return _cached;
|
|
23
|
-
} catch {
|
|
24
|
-
return DEFAULT_CONFIG;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function saveConfig(updates) {
|
|
28
|
-
const current = await loadConfig();
|
|
29
|
-
const next = ConfigSchema.parse({
|
|
30
|
-
...current,
|
|
31
|
-
...updates
|
|
32
|
-
});
|
|
33
|
-
const p = configPath();
|
|
34
|
-
await mkdir(path.dirname(p), { recursive: true });
|
|
35
|
-
await writeFile(p, JSON.stringify(next, null, 2) + "\n", { mode: 384 });
|
|
36
|
-
_cached = next;
|
|
37
|
-
}
|
|
38
|
-
async function resetConfigCache() {
|
|
39
|
-
_cached = null;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
export { saveConfig as i, loadConfig as n, resetConfigCache as r, config_exports as t };
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=config-9KYXaAv-.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-9KYXaAv-.mjs","names":[],"sources":["../src/config/index.ts"],"sourcesContent":["import { readFile, writeFile, mkdir } from 'node:fs/promises'\nimport path from 'node:path'\nimport os from 'node:os'\nimport { ConfigSchema, DEFAULT_CONFIG, type InvestigatorConfig } from './schema.js'\n\n// Config path derived from HOME at call time so tests can override HOME.\nfunction configPath(): string {\n return path.join(os.homedir(), '.chain-insights', 'config.json')\n}\n\nlet _cached: InvestigatorConfig | null = null\n\nexport async function loadConfig(): Promise<InvestigatorConfig> {\n if (_cached) return _cached\n try {\n const raw = await readFile(configPath(), 'utf8')\n const parsed = JSON.parse(raw) as unknown\n _cached = ConfigSchema.parse(parsed)\n return _cached\n } catch {\n return DEFAULT_CONFIG\n }\n}\n\nexport async function saveConfig(updates: Partial<InvestigatorConfig>): Promise<void> {\n const current = await loadConfig()\n const next = ConfigSchema.parse({ ...current, ...updates })\n const p = configPath()\n await mkdir(path.dirname(p), { recursive: true })\n await writeFile(p, JSON.stringify(next, null, 2) + '\\n', { mode: 0o600 })\n _cached = next\n}\n\nexport async function resetConfigCache(): Promise<void> {\n _cached = null\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAS,aAAqB;CAC5B,OAAO,KAAK,KAAK,GAAG,QAAQ,GAAG,mBAAmB,aAAa;AACjE;AAEA,IAAI,UAAqC;AAEzC,eAAsB,aAA0C;CAC9D,IAAI,SAAS,OAAO;CACpB,IAAI;EACF,MAAM,MAAM,MAAM,SAAS,WAAW,GAAG,MAAM;EAC/C,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,UAAU,aAAa,MAAM,MAAM;EACnC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,WAAW,SAAqD;CACpF,MAAM,UAAU,MAAM,WAAW;CACjC,MAAM,OAAO,aAAa,MAAM;EAAE,GAAG;EAAS,GAAG;CAAQ,CAAC;CAC1D,MAAM,IAAI,WAAW;CACrB,MAAM,MAAM,KAAK,QAAQ,CAAC,GAAG,EAAE,WAAW,KAAK,CAAC;CAChD,MAAM,UAAU,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,IAAM,CAAC;CACxE,UAAU;AACZ;AAEA,eAAsB,mBAAkC;CACtD,UAAU;AACZ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init-CZbZegIW.mjs","names":[],"sources":["../src/workspace/init.ts"],"sourcesContent":["import { access, mkdir, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nexport interface InitWorkspaceOptions {\n targetDir: string\n force?: boolean\n}\n\nexport interface InitWorkspaceResult {\n workspaceRoot: string\n filesWritten: string[]\n}\n\nconst WORKSPACE_DIRS = [\n '.chain-insights',\n '.chain-insights/schema',\n '.chain-insights/runtime',\n '.chain-insights/runtime/logs',\n '.chain-insights/runtime-skill',\n 'cases',\n 'imports',\n 'reports',\n 'reports/graphs',\n 'reports/tables',\n 'templates',\n]\n\nfunction todayIso(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction workspaceJson(workspaceRoot: string): string {\n return JSON.stringify({\n schema: 'chain-insights.workspace.v1',\n name: 'Chain Insights Investigations',\n workspace_root: workspaceRoot,\n default_network: 'bittensor',\n graph_mcp_endpoint: 'https://staging-mcp.chain-insights.ai/mcp',\n cases_dir: 'cases',\n imports_dir: 'imports',\n reports_dir: 'reports',\n templates_dir: 'templates',\n created_at: todayIso(),\n }, null, 2) + '\\n'\n}\n\nconst README = `# Chain Insights Investigations\n\nThis is a workspace for Chain Insights AML investigations.\n\n## Start\n\n\\`\\`\\`bash\nchain-insights mcp tools --refresh\nchain-insights wallet balance\n\\`\\`\\`\n\n## Layout\n\n\\`\\`\\`text\n.chain-insights/ Workspace metadata\ncases/ Case exports and notes\nimports/ External reports, CSVs, screenshots, raw notes\nreports/ Final or interim analyst reports\nreports/graphs/ Graph JSON for visualization\nreports/tables/ Compact tabular extracts\ntemplates/ Reusable case/report templates\n.chain-insights/schema/ Runtime graph schema captures\n.chain-insights/runtime/ Workspace-local runtime process state and debug logs\n.chain-insights/runtime-skill/ Workspace-specific agent schema notes\n\\`\\`\\`\n`\n\nconst AGENTS = `# Agent Instructions\n\nYou are operating inside a Chain Insights investigation workspace.\n\n- Read README.md first.\n- If this directory is not initialized, run \\`cia init .\\` before investigation-producing commands.\n- Do not rerun init in an existing workspace unless replacing scaffolding with \\`--force\\`.\n- Read .chain-insights/runtime-skill/SKILL.md before graph queries.\n- Preserve full blockchain addresses exactly.\n- Do not guess the network for graph queries.\n- Capture or refresh graph schema before the first case query.\n- Save compact evidence with original graph field names.\n- Put canonical graph JSON in reports/graphs/ and analyst tables in reports/tables/.\n- Evidence files should summarize and point to graph/table outputs; do not paste large raw JSON blobs into evidence Markdown.\n- Investigation output must stay in this initialized workspace.\n- Never write cases, evidence, reports, graph JSON, HTML, schema captures, or logs to ~/.chain-insights.\n- Keep theories lightweight until evidence supports them.\n`\n\nconst CLAUDE = AGENTS\n\nconst CASE_BRIEF = `# Case Brief\n\n## Summary\n\nStatus:\nNetwork:\nCurrent Assessment:\n\n## Known Addresses\n\n## Claims To Validate\n\n## Evidence\n\n## Next Steps\n`\n\nconst IMPORTS_README = `# External Investigation Inputs\n\nPut user-provided or third-party investigation material here before turning it\ninto case evidence.\n\nExamples:\n\n- Exchange support exports\n- CSV extracts\n- Screenshots\n- Raw notes\n- Partner reports\n\nFiles in this directory are inputs, not verified evidence. When an import\nsupports a claim, summarize it into the case evidence manifest and reference\nthe original file path.\n`\n\nconst TEMPLATES_README = `# Reusable Workspace Templates\n\nStore local report, case, prompt, and evidence templates here.\n\nTemplates are optional workspace helpers. They are not evidence and should not\nbe treated as case state until copied into a case, evidence file, dossier, or\nreport.\n`\n\nconst RUNTIME_SKILL = `---\nname: chain-insights-runtime-schema\ndescription: Workspace-local Chain Insights runtime schema notes. Refresh this after connecting to a graph MCP endpoint.\n---\n\n# Runtime Graph Schema\n\nBefore the first investigation query, capture the live graph schema into:\n\n\\`\\`\\`text\n.chain-insights/schema/<network>.graph-schema.json\n\\`\\`\\`\n\nUse \\`graph_query_batch\\` for schema capture. Prefix current topology reads\nwith \\`USE live_topology\\`, historical topology reads with\n\\`USE archive_topology\\`, and fact reads with \\`USE facts\\`, for example:\n\n\\`\\`\\`bash\ncia mcp call graph_query_batch network=<network> 'queries=[{\"id\":\"node_labels\",\"query\":\"USE live_topology MATCH (n:Address) RETURN \\\"Address\\\" AS node_label, count(n) AS sample_count LIMIT 1\"},{\"id\":\"archive_flow_sample\",\"query\":\"USE archive_topology MATCH (:Address)-[f:FLOWS_TO]->(:Address) RETURN f.period_granularity AS granularity, f.amount_sum AS amount_sum LIMIT 20\"}]'\n\\`\\`\\`\n\nThen update this file with observed labels, relationship types, and allowed\nproperty names for the active network.\n\nRules:\n\n- Prefer \\`graph_query\\` and \\`graph_query_batch\\` for graph-language reads.\n- Use \\`USE live_topology\\` for recent topology, \\`USE archive_topology\\`\n for historical topology, and \\`USE facts\\` for labels, features,\n risk scores, assets, and enrichment. Address facts can be reached through\n relationships such as \\`(:Address)-[:HAS_FEATURE]->(:AddressFeature)\\`.\n Archived money-flow topology is exposed as\n \\`(:Address)-[:FLOWS_TO]->(:Address)\\` with \\`period_granularity\\`,\n \\`period_start_date\\`, and \\`period_end_date\\` on the relationship.\n- Preserve source schema field names in evidence and generated data files.\n- Do not rename, reinterpret, or add unit labels to graph fields unless the\n schema or query result explicitly supports that interpretation.\n- Keep evidence compact: select only the fields needed to support the claim.\n Avoid storing whole node or relationship property blobs in evidence unless\n the purpose of the query is schema discovery or debugging.\n- Keep analysis products separate from evidence: graph JSON belongs under\n \\`reports/graphs/\\`, tabular extracts under \\`reports/tables/\\`, and analyst\n narrative under \\`reports/\\`.\n- Evidence Markdown should be a short provenance record with key facts and\n pointers. Large JSON belongs in \\`reports/tables/\\`, not inline in evidence.\n`\n\nconst SCHEMA_README = `# Runtime Schema Captures\n\nStore graph schema captures here, for example:\n\n\\`\\`\\`text\nbittensor.graph-schema.json\n\\`\\`\\`\n\nSchema captures should be generated before the first case query in a fresh\nworkspace, then referenced by evidence, reports, and runtime skill notes.\n`\n\nfunction workspaceFiles(workspaceRoot: string): Array<[string, string]> {\n return [\n ['.chain-insights/workspace.json', workspaceJson(workspaceRoot)],\n ['README.md', README],\n ['AGENTS.md', AGENTS],\n ['CLAUDE.md', CLAUDE],\n ['imports/README.md', IMPORTS_README],\n ['templates/README.md', TEMPLATES_README],\n ['templates/case-brief.md', CASE_BRIEF],\n ['.chain-insights/runtime-skill/SKILL.md', RUNTIME_SKILL],\n ['.chain-insights/schema/README.md', SCHEMA_README],\n ['.chain-insights/runtime/.keep', ''],\n ['.chain-insights/runtime/logs/.keep', ''],\n ]\n}\n\nasync function assertNoFileCollisions(workspaceRoot: string): Promise<void> {\n for (const [relativePath] of workspaceFiles(workspaceRoot)) {\n const filePath = path.join(workspaceRoot, relativePath)\n try {\n await access(filePath)\n throw new Error(`Refusing to overwrite ${filePath}. Re-run with --force to replace workspace files.`)\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n continue\n }\n throw err\n }\n }\n}\n\nexport async function initWorkspace(options: InitWorkspaceOptions): Promise<InitWorkspaceResult> {\n const workspaceRoot = path.resolve(options.targetDir)\n if (!options.force) {\n await assertNoFileCollisions(workspaceRoot)\n }\n\n for (const dir of WORKSPACE_DIRS) {\n await mkdir(path.join(workspaceRoot, dir), { recursive: true })\n }\n\n const filesWritten: string[] = []\n const flag = options.force ? 'w' : 'wx'\n for (const [relativePath, content] of workspaceFiles(workspaceRoot)) {\n const filePath = path.join(workspaceRoot, relativePath)\n try {\n await writeFile(filePath, content, { mode: 0o600, flag })\n filesWritten.push(relativePath)\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') {\n throw new Error(`Refusing to overwrite ${filePath}. Re-run with --force to replace workspace files.`)\n }\n throw err\n }\n }\n\n return { workspaceRoot, filesWritten }\n}\n"],"mappings":";;;AAaA,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,WAAmB;CAC1B,wBAAO,IAAI,KAAK,GAAE,YAAY,EAAE,MAAM,GAAG,EAAE;AAC7C;AAEA,SAAS,cAAc,eAA+B;CACpD,OAAO,KAAK,UAAU;EACpB,QAAQ;EACR,MAAM;EACN,gBAAgB;EAChB,iBAAiB;EACjB,oBAAoB;EACpB,WAAW;EACX,aAAa;EACb,aAAa;EACb,eAAe;EACf,YAAY,SAAS;CACvB,GAAG,MAAM,CAAC,IAAI;AAChB;AAEA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Bf,MAAM,SAAS;;;;;;;;;;;;;;;;;;AAmBf,MAAM,SAAS;AAEf,MAAM,aAAa;;;;;;;;;;;;;;;;AAiBnB,MAAM,iBAAiB;;;;;;;;;;;;;;;;;AAkBvB,MAAM,mBAAmB;;;;;;;;AASzB,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CtB,MAAM,gBAAgB;;;;;;;;;;;AAYtB,SAAS,eAAe,eAAgD;CACtE,OAAO;EACL,CAAC,kCAAkC,cAAc,aAAa,CAAC;EAC/D,CAAC,aAAa,MAAM;EACpB,CAAC,aAAa,MAAM;EACpB,CAAC,aAAa,MAAM;EACpB,CAAC,qBAAqB,cAAc;EACpC,CAAC,uBAAuB,gBAAgB;EACxC,CAAC,2BAA2B,UAAU;EACtC,CAAC,0CAA0C,aAAa;EACxD,CAAC,oCAAoC,aAAa;EAClD,CAAC,iCAAiC,EAAE;EACpC,CAAC,sCAAsC,EAAE;CAC3C;AACF;AAEA,eAAe,uBAAuB,eAAsC;CAC1E,KAAK,MAAM,CAAC,iBAAiB,eAAe,aAAa,GAAG;EAC1D,MAAM,WAAW,KAAK,KAAK,eAAe,YAAY;EACtD,IAAI;GACF,MAAM,OAAO,QAAQ;GACrB,MAAM,IAAI,MAAM,yBAAyB,SAAS,kDAAkD;EACtG,SAAS,KAAK;GACZ,IAAK,IAA8B,SAAS,UAC1C;GAEF,MAAM;EACR;CACF;AACF;AAEA,eAAsB,cAAc,SAA6D;CAC/F,MAAM,gBAAgB,KAAK,QAAQ,QAAQ,SAAS;CACpD,IAAI,CAAC,QAAQ,OACX,MAAM,uBAAuB,aAAa;CAG5C,KAAK,MAAM,OAAO,gBAChB,MAAM,MAAM,KAAK,KAAK,eAAe,GAAG,GAAG,EAAE,WAAW,KAAK,CAAC;CAGhE,MAAM,eAAyB,CAAC;CAChC,MAAM,OAAO,QAAQ,QAAQ,MAAM;CACnC,KAAK,MAAM,CAAC,cAAc,YAAY,eAAe,aAAa,GAAG;EACnE,MAAM,WAAW,KAAK,KAAK,eAAe,YAAY;EACtD,IAAI;GACF,MAAM,UAAU,UAAU,SAAS;IAAE,MAAM;IAAO;GAAK,CAAC;GACxD,aAAa,KAAK,YAAY;EAChC,SAAS,KAAK;GACZ,IAAK,IAA8B,SAAS,UAC1C,MAAM,IAAI,MAAM,yBAAyB,SAAS,kDAAkD;GAEtG,MAAM;EACR;CACF;CAEA,OAAO;EAAE;EAAe;CAAa;AACvC"}
|