konoha-mcp 2.2.24 → 2.2.25
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/NOTICE +14 -46
- package/README.md +19 -4
- package/apps/web/build/adapter-node.js +1 -1
- package/apps/web/build/build-meta.json +2 -2
- package/apps/web/build/client/_app/immutable/entry/{app.CKJ0NhrX.js → app.DtoBIrs4.js} +2 -2
- package/apps/web/build/client/_app/immutable/entry/app.DtoBIrs4.js.br +0 -0
- package/apps/web/build/client/_app/immutable/entry/app.DtoBIrs4.js.gz +0 -0
- package/apps/web/build/client/_app/immutable/nodes/{0.7A6fQJ6z.js → 0.B8Iw7Xl1.js} +1 -1
- package/apps/web/build/client/_app/immutable/nodes/0.B8Iw7Xl1.js.br +0 -0
- package/apps/web/build/client/_app/immutable/nodes/{0.7A6fQJ6z.js.gz → 0.B8Iw7Xl1.js.gz} +0 -0
- package/apps/web/build/client/_app/version.json +1 -1
- package/apps/web/build/client/_app/version.json.br +0 -0
- package/apps/web/build/client/_app/version.json.gz +0 -0
- package/apps/web/build/server/chunks/instance.js +3 -3
- package/apps/web/build/server/chunks/internal.js +1 -1
- package/apps/web/build/server/entries/pages/_layout.svelte.js +1 -1
- package/apps/web/build/server/entries/pages/_layout.svelte.js.map +1 -1
- package/apps/web/build/server/manifest-full.js +1 -1
- package/apps/web/build/server/manifest.js +1 -1
- package/apps/web/build/server/nodes/0.js +1 -1
- package/apps/web/build/server/server.js +1 -1
- package/apps/web/package.json +1 -1
- package/assets/demo-agy.webp +0 -0
- package/assets/demo-claude.webp +0 -0
- package/assets/demo-codex.webp +0 -0
- package/assets/demo-commandcode.webp +0 -0
- package/assets/demo-cursor.webp +0 -0
- package/assets/demo-opencode.webp +0 -0
- package/assets/demo-pi.webp +0 -0
- package/assets/demo-skill-embed.webp +0 -0
- package/assets/demo-skills.webp +0 -0
- package/assets/demo-web.webp +0 -0
- package/assets/demo.webp +0 -0
- package/assets/konoha-akatsuki-flow.webp +0 -0
- package/assets/konoha-anbu-flow.webp +0 -0
- package/assets/konoha-flow-12-cli-upgrade-progress-engine.webp +0 -0
- package/assets/konoha-jonin-flow.webp +0 -0
- package/assets/konoha-kage-gate.webp +0 -0
- package/assets/konoha-langgraph-flow.webp +0 -0
- package/assets/konoha-orchestration-flow.webp +0 -0
- package/assets/konoha-qa-flow.webp +0 -0
- package/assets/konoha-telegram-flow.webp +0 -0
- package/assets/testing.webp +0 -0
- package/bin/commands/init.js +13 -3
- package/bin/commands/init_migration.js +32 -1
- package/bin/lib/runtime_install.js +6 -0
- package/node_modules/jszip/package.json +2 -2
- package/node_modules/string_decoder/package.json +1 -1
- package/package.json +9 -3
- package/patches/jszip@3.10.2.patch +11 -0
- package/patches/string_decoder@1.3.0.patch +12 -0
- package/src/agent_contract.js +2 -2
- package/src/antigravity_subagent_hook.js +30 -12
- package/src/chunin_knowledge_ddl.js +95 -0
- package/src/db_schema.js +4 -1
- package/src/deploy_installer.js +212 -11
- package/src/deploy_utils.js +4 -0
- package/src/file_tools/common.js +65 -3
- package/src/file_tools_router.js +67 -6
- package/src/mcp/chunin_knowledge.js +509 -0
- package/src/mcp/tool_dispatch.js +2 -1
- package/src/mcp/web_search.js +27 -3
- package/src/mcp_clients/common.js +31 -0
- package/src/mcp_tool_manifest.json +31 -0
- package/src/pi_fs_helpers.js +31 -0
- package/src/pi_manager.js +68 -28
- package/src/templates/AGENTS.md +1 -1
- package/src/templates/GEMINI.md +1 -1
- package/src/templates/skills/chunin-skill/SKILL.md +34 -0
- package/src/templates/skills/chunin-skill/references/deep-research-analyst.md +27 -10
- package/src/templates/skills/konoha/SKILL.md +1 -1
- package/src/templates/skills/konoha/references/contract.md +1 -1
- package/src/templates/skills/konoha/references/peragent-usage.md +1 -1
- package/src/url_canonical.js +58 -0
- package/src/vector_pipeline.js +6 -4
- package/src/vector_search.js +4 -2
- package/apps/web/build/client/_app/immutable/entry/app.CKJ0NhrX.js.br +0 -0
- package/apps/web/build/client/_app/immutable/entry/app.CKJ0NhrX.js.gz +0 -0
- package/apps/web/build/client/_app/immutable/nodes/0.7A6fQJ6z.js.br +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Small filesystem helpers shared by the Pi integration. They live here rather
|
|
4
|
+
// than in pi_manager.js so that module stays under the 700-line ceiling the repo
|
|
5
|
+
// lints at; none of them carry Pi-specific behaviour.
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
function fileExists(p) {
|
|
10
|
+
try {
|
|
11
|
+
return fs.existsSync(p);
|
|
12
|
+
} catch (_) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function readJsonSafe(filePath) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
20
|
+
} catch (_) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ensureDirSafe(dir) {
|
|
26
|
+
try {
|
|
27
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
28
|
+
} catch (_) { /* best effort: a failed mkdir must never crash the CLI or MCP runtime */ }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { fileExists, readJsonSafe, ensureDirSafe };
|
package/src/pi_manager.js
CHANGED
|
@@ -13,6 +13,7 @@ const { buildPiBlockerExtensionSource } = require('./pi_blocker_template');
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const fs = require('fs');
|
|
16
|
+
const { fileExists, readJsonSafe, ensureDirSafe } = require('./pi_fs_helpers');
|
|
16
17
|
const path = require('path');
|
|
17
18
|
const { AISLOP_PACKAGE } = require('./uvx_runtime');
|
|
18
19
|
const os = require('os');
|
|
@@ -134,6 +135,43 @@ function buildPiManagedContract() {
|
|
|
134
135
|
* Deploys the Konoha runtime contract + Pi workflow mandate into
|
|
135
136
|
* ~/.pi/agent/AGENTS.md (Pi's global context file) using managed markers.
|
|
136
137
|
*/
|
|
138
|
+
/**
|
|
139
|
+
* Writes one Pi agent profile per deployable agent.
|
|
140
|
+
*
|
|
141
|
+
* Pi used to receive the advisor profile only, so `subagent(agent="chunin")` had no
|
|
142
|
+
* definition to resolve and every delegation failed with UNSUPPORTED_NATIVE_SPAWN even
|
|
143
|
+
* with pi-subagents installed. Tools are written as a YAML sequence: pi-subagents reads
|
|
144
|
+
* `tools: read, grep, find, ls` as a single tool name and then rejects the launch.
|
|
145
|
+
*
|
|
146
|
+
* @returns {string[]} agent names written
|
|
147
|
+
*/
|
|
148
|
+
function deployPiAgentProfiles(piAgentsDir, options = {}) {
|
|
149
|
+
const silent = options.silent !== false;
|
|
150
|
+
const { getDeployableAgents } = require('./canonical_agents');
|
|
151
|
+
const { buildSubagentContract } = require('./agent_contract');
|
|
152
|
+
const { writeAgentFileSafe, AGENT_OWNERSHIP_MARKER, getRoleDescription } = require('./agent_file_safety');
|
|
153
|
+
const { buildPiSubagentToolGrants } = require('./mcp_clients/common');
|
|
154
|
+
const written = [];
|
|
155
|
+
for (const agent of getDeployableAgents()) {
|
|
156
|
+
const grants = buildPiSubagentToolGrants(agent);
|
|
157
|
+
const description = String(getRoleDescription(agent) || '').replace(/"/g, '\\"').replace(/\n/g, ' ');
|
|
158
|
+
const frontmatter = [
|
|
159
|
+
'---',
|
|
160
|
+
`name: ${agent.name}`,
|
|
161
|
+
`description: "${description}"`,
|
|
162
|
+
AGENT_OWNERSHIP_MARKER,
|
|
163
|
+
'tools:',
|
|
164
|
+
...grants.map((t) => ` - ${t}`),
|
|
165
|
+
'---',
|
|
166
|
+
''
|
|
167
|
+
].join('\n');
|
|
168
|
+
const body = `${agent.instructions}\n\n${buildSubagentContract('pi')}\n`;
|
|
169
|
+
writeAgentFileSafe(path.join(piAgentsDir, `${agent.name}.md`), frontmatter + body, agent.name, { silent });
|
|
170
|
+
written.push(agent.name);
|
|
171
|
+
}
|
|
172
|
+
return written;
|
|
173
|
+
}
|
|
174
|
+
|
|
137
175
|
function deployPiContract(silent = true, targetFile = null, options = {}) {
|
|
138
176
|
const opts = typeof targetFile === "object" && targetFile !== null ? targetFile : options;
|
|
139
177
|
const explicitTarget = typeof targetFile === "string" ? targetFile : (opts && opts.targetFile);
|
|
@@ -323,14 +361,6 @@ function removePiBlockerExtension(silent = true) {
|
|
|
323
361
|
}
|
|
324
362
|
}
|
|
325
363
|
|
|
326
|
-
function fileExists(p) {
|
|
327
|
-
try {
|
|
328
|
-
return fs.existsSync(p);
|
|
329
|
-
} catch (_) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
364
|
function isPiInstalled() {
|
|
335
365
|
if (fileExists(path.join(HOME, '.pi', 'agent'))) return true;
|
|
336
366
|
try {
|
|
@@ -343,14 +373,6 @@ function isPiInstalled() {
|
|
|
343
373
|
}
|
|
344
374
|
}
|
|
345
375
|
|
|
346
|
-
function readJsonSafe(filePath) {
|
|
347
|
-
try {
|
|
348
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
349
|
-
} catch (_) {
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
376
|
function _handleCorruptPiSettings(settingsPath, isSilent) {
|
|
355
377
|
try {
|
|
356
378
|
fs.copyFileSync(settingsPath, settingsPath + '.corrupt-' + Date.now());
|
|
@@ -511,14 +533,9 @@ function ensurePiSetup(options = {}) {
|
|
|
511
533
|
const rtk = deployPiRtkRule(silent);
|
|
512
534
|
const contract = deployPiContract(silent, null, options);
|
|
513
535
|
const blocker = deployPiBlockerExtension(silent, options);
|
|
514
|
-
const { getAdvisorAgentDefinition } = require('./canonical_agents');
|
|
515
|
-
const { buildSubagentContract } = require('./agent_contract');
|
|
516
|
-
const { writeAgentFileSafe, AGENT_OWNERSHIP_MARKER, getRoleDescription } = require('./agent_file_safety');
|
|
517
|
-
const adv = getAdvisorAgentDefinition();
|
|
518
536
|
const piAgentsDir = path.join(agentDir, 'agents');
|
|
519
537
|
ensureDirSafe(piAgentsDir);
|
|
520
|
-
const
|
|
521
|
-
writeAgentFileSafe(path.join(piAgentsDir, 'advisor.md'), advMd, 'advisor', { silent });
|
|
538
|
+
const deployedAgents = deployPiAgentProfiles(piAgentsDir, { silent });
|
|
522
539
|
|
|
523
540
|
const projectRoot = options.projectRoot || null;
|
|
524
541
|
const projMcp = projectRoot ? path.join(projectRoot, '.pi', 'mcp.json') : null;
|
|
@@ -534,6 +551,7 @@ function ensurePiSetup(options = {}) {
|
|
|
534
551
|
return {
|
|
535
552
|
ok: true,
|
|
536
553
|
changed: !!(adapter.changed || contract.changed || blocker.changed),
|
|
554
|
+
agentsDeployed: deployedAgents,
|
|
537
555
|
rtkDeployed: !!rtk.ok,
|
|
538
556
|
contractDeployed: !!contract.ok,
|
|
539
557
|
blockerDeployed: !!blocker.ok
|
|
@@ -591,6 +609,22 @@ function _readPiAgentsContent() {
|
|
|
591
609
|
}
|
|
592
610
|
}
|
|
593
611
|
|
|
612
|
+
/**
|
|
613
|
+
* Agent profile names present in a Pi agents directory, without the extension.
|
|
614
|
+
*
|
|
615
|
+
* @returns {string[]} sorted names, empty when the directory is absent
|
|
616
|
+
*/
|
|
617
|
+
function readPiAgentProfileNames(agentsDir) {
|
|
618
|
+
try {
|
|
619
|
+
return fs.readdirSync(agentsDir)
|
|
620
|
+
.filter((f) => f.endsWith('.md'))
|
|
621
|
+
.map((f) => f.slice(0, -3))
|
|
622
|
+
.sort();
|
|
623
|
+
} catch (_) { /* absent directory: no profiles deployed yet */
|
|
624
|
+
return [];
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
594
628
|
function getPiStatus(options = {}) {
|
|
595
629
|
const installed = isPiInstalled();
|
|
596
630
|
const { mcpKonoha, mcpAislop } = _readPiMcpServerFlags();
|
|
@@ -600,6 +634,11 @@ function getPiStatus(options = {}) {
|
|
|
600
634
|
const agentsContent = _readPiAgentsContent();
|
|
601
635
|
const rtkRuleDeployed = fileExists(PI_RTK_EXTENSION) || agentsContent.includes(RTK_BLOCK_START);
|
|
602
636
|
const contractDeployed = agentsContent.includes('<!-- KONOHA-CONTRACT-START -->');
|
|
637
|
+
const agentDir = options.agentDir || (options.home ? path.join(options.home, '.pi', 'agent') : PI_AGENT_DIR);
|
|
638
|
+
const agentProfiles = readPiAgentProfileNames(path.join(agentDir, 'agents'));
|
|
639
|
+
const missingAgentProfiles = require('./canonical_agents')
|
|
640
|
+
.getDeployableAgentNames()
|
|
641
|
+
.filter((name) => !agentProfiles.includes(name));
|
|
603
642
|
|
|
604
643
|
return {
|
|
605
644
|
installed,
|
|
@@ -611,16 +650,15 @@ function getPiStatus(options = {}) {
|
|
|
611
650
|
contractDeployed,
|
|
612
651
|
blockerDeployed,
|
|
613
652
|
subagentExtensionInstalled,
|
|
653
|
+
// A subagent extension alone cannot spawn anything: the harness also needs a
|
|
654
|
+
// profile per agent, which is what this field makes visible.
|
|
655
|
+
agentProfiles,
|
|
656
|
+
missingAgentProfiles,
|
|
657
|
+
agentRosterComplete: missingAgentProfiles.length === 0,
|
|
614
658
|
configPath: PI_MCP_CONFIG
|
|
615
659
|
};
|
|
616
660
|
}
|
|
617
661
|
|
|
618
|
-
function ensureDirSafe(dir) {
|
|
619
|
-
try {
|
|
620
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
621
|
-
} catch (_) { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
|
|
622
|
-
}
|
|
623
|
-
|
|
624
662
|
module.exports = {
|
|
625
663
|
PI_AGENT_DIR,
|
|
626
664
|
PI_SETTINGS,
|
|
@@ -639,6 +677,8 @@ module.exports = {
|
|
|
639
677
|
registerPiMcp,
|
|
640
678
|
deployPiRtkRule,
|
|
641
679
|
deployPiContract,
|
|
680
|
+
deployPiAgentProfiles,
|
|
681
|
+
readPiAgentProfileNames,
|
|
642
682
|
stripStalePiMandates,
|
|
643
683
|
deployPiBlockerExtension,
|
|
644
684
|
removePiBlockerExtension,
|
package/src/templates/AGENTS.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
NEVER run destructive commands (`rm -rf`, `DROP`, `git reset`) or view secrets (`.env*`).
|
|
16
16
|
|
|
17
17
|
<!-- KONOHA-CONTRACT-START -->
|
|
18
|
-
## Konoha runtime contract (2.2.
|
|
18
|
+
## Konoha runtime contract (2.2.25)
|
|
19
19
|
main agent on Antigravity IDE/CLI. Mandatory every turn.
|
|
20
20
|
- **Konoha is mandatory**: `find_skill`/`get_skill`; no raw cat/grep.
|
|
21
21
|
- **Code intelligence is mandatory**: `code_search`/`code_symbol`/`code_impact`, absolute root.
|
package/src/templates/GEMINI.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
NEVER run destructive commands (`rm -rf`, `DROP`, `git reset`) or view secrets (`.env*`).
|
|
16
16
|
|
|
17
17
|
<!-- KONOHA-CONTRACT-START -->
|
|
18
|
-
## Konoha runtime contract (2.2.
|
|
18
|
+
## Konoha runtime contract (2.2.25)
|
|
19
19
|
main agent on Antigravity IDE/CLI. Mandatory every turn.
|
|
20
20
|
- **Konoha is mandatory**: `find_skill`/`get_skill`; no raw cat/grep.
|
|
21
21
|
- **Code intelligence is mandatory**: `code_search`/`code_symbol`/`code_impact`, absolute root.
|
|
@@ -69,6 +69,40 @@ Evaluate all discovered sources against the 4-tier credibility matrix:
|
|
|
69
69
|
3. Explicitly report discrepancies, deprecated APIs, and version-specific divergences.
|
|
70
70
|
4. Record exact versions, dates, and publication status for all referenced libraries.
|
|
71
71
|
|
|
72
|
+
### SOP 4: Deep Research Loop (cache-first, batched)
|
|
73
|
+
|
|
74
|
+
Research runs cache-first so a repeated topic costs no network at all. The loop
|
|
75
|
+
follows the dzhng/deep-research shape, implemented in `src/mcp/chunin_knowledge.js`.
|
|
76
|
+
|
|
77
|
+
1. **Retrieve before searching.** Query the local `chunin_knowledge` store for the
|
|
78
|
+
**top 5** references relevant to the topic (`retrieveRelevant`, hybrid FTS5 +
|
|
79
|
+
vector + cross-encoder rerank). Seed `visitedUrls` and `learnings` from them.
|
|
80
|
+
Skip this only when `use_knowledge_cache: false`.
|
|
81
|
+
2. **Search only for what is new.** Call `web_search` with `exclude_urls` set to the
|
|
82
|
+
retrieved canonical URLs and take the **top 3** net-new results. URLs are
|
|
83
|
+
canonicalized (scheme forced to https, host lowercased, `utm_*`/`fbclid`/`gclid`
|
|
84
|
+
dropped, query sorted, trailing slash and `index.html` removed), so one page
|
|
85
|
+
reached by two spellings is fetched once.
|
|
86
|
+
3. **Deduplicate before storing.** A learning is dropped when its `content_hash`
|
|
87
|
+
matches an existing one, when its canonical URL is already known, or when its
|
|
88
|
+
embedding scores `>= 0.90` cosine against a known learning. That cosine is
|
|
89
|
+
computed on **mean-centered** vectors: the embedder's raw cosine rates two
|
|
90
|
+
unrelated sentences at ~0.997, so the raw value cannot separate duplicates from
|
|
91
|
+
distinct claims.
|
|
92
|
+
4. **Store in one batched write.** Surviving learnings are embedded with a single
|
|
93
|
+
`embedBatch` call (batched ONNX inference, length-sorted so padding is not
|
|
94
|
+
wasted) and inserted in one transaction with a prepared statement.
|
|
95
|
+
5. **Recurse.** `breadth` (default 3, max 5) queries per level, `depth` (default 2,
|
|
96
|
+
max 3) levels, with `nextBreadth = ceil(breadth / 2)`. Learnings, follow-up
|
|
97
|
+
questions and visited URLs accumulate across levels; raw page bodies are
|
|
98
|
+
discarded after extraction.
|
|
99
|
+
6. **Report.** `output_mode: "report"` keeps citations and follow-ups;
|
|
100
|
+
`"concise"` returns the learnings alone.
|
|
101
|
+
|
|
102
|
+
A store that was never embedded still answers: retrieval falls back to FTS, then to
|
|
103
|
+
the most recent rows for the topic, and storage keeps the text without a vector
|
|
104
|
+
when the semantic runtime is unavailable. Degrade, never fail.
|
|
105
|
+
|
|
72
106
|
### SOP 4: Cited Technical Intel Report Schema
|
|
73
107
|
Deliver research findings structured in the standardized format:
|
|
74
108
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: deep-research-analyst
|
|
3
3
|
description: "Expert guide for autonomous deep research, iterative web search, citation verification, evidence graph synthesis, and hallucination mitigation / Panduan ahli riset mendalam otonom, pencarian web iteratif, verifikasi sitasi, dan mitigasi halusinasi."
|
|
4
|
-
author: vibes-plug-swarm
|
|
4
|
+
author: vibes-plug-swarm
|
|
5
5
|
version: "3.0.0"
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -110,16 +110,33 @@ async def deep_research(query: str) -> list[ResearchFinding]:
|
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
#### 3. Vector Store Caching for Intermediate Results
|
|
113
|
-
Caching intermediate research results
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
Caching intermediate research results prevents redundant crawling and accelerates
|
|
114
|
+
retrieval. Konoha implements this locally in `src/mcp/chunin_knowledge.js` — no
|
|
115
|
+
pgvector, no FAISS, no API key:
|
|
116
|
+
|
|
117
|
+
- **Storage:** the `chunin_knowledge` table (schema v11) with an FTS5 index and a
|
|
118
|
+
384-dim FLOAT32 `embedding` column registered through the bundled
|
|
119
|
+
`sqlite-vector` extension (`vector_init`, distance COSINE, normalized).
|
|
120
|
+
- **Retrieval order:** **top-5** stored references for the topic (FTS5 + vector +
|
|
121
|
+
cross-encoder rerank) before any network call; then **top-3** net-new web
|
|
122
|
+
results via `web_search({ exclude_urls })`.
|
|
123
|
+
- **Deduplication, three layers:** exact `content_hash`; canonical URL (tracking
|
|
124
|
+
params, trailing slash, scheme and host case normalized); and cosine `>= 0.90`
|
|
125
|
+
over **mean-centered** embeddings. Centering matters: the raw embedder rates two
|
|
126
|
+
unrelated sentences at ~0.997 cosine, so an uncentered threshold marks everything
|
|
127
|
+
as a duplicate. Measured after centering, unrelated pairs fall to -0.46..0.41 and
|
|
128
|
+
identical text stays at 1.0.
|
|
129
|
+
- **Bulk write:** surviving learnings are embedded in one batched `embedBatch` call
|
|
130
|
+
(real ONNX batching, length-sorted to avoid padding waste) and inserted in a
|
|
131
|
+
single transaction with a prepared statement.
|
|
132
|
+
- **Invalidation:** `last_verified_at` is per row; refresh it when a learning is
|
|
133
|
+
re-confirmed. Time-sensitive topics should re-search rather than trust the cache.
|
|
117
134
|
- **Example Flow:**
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
```js
|
|
136
|
+
const { retrieveRelevant, storeLearnings } = require('./mcp/chunin_knowledge');
|
|
137
|
+
const known = await retrieveRelevant({ topic, topK: 5 });
|
|
138
|
+
const fresh = await web_search({ query: topic, exclude_urls: known.map(r => r.canonical_url) });
|
|
139
|
+
await storeLearnings({ topic, learnings: fresh });
|
|
123
140
|
```
|
|
124
141
|
|
|
125
142
|
#### 4. Episodic Research Memory
|
|
@@ -10,7 +10,7 @@ tags:
|
|
|
10
10
|
- fts5
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
# 🍃 Konoha MCP Tools Orchestrator Skill (v2.2.
|
|
13
|
+
# 🍃 Konoha MCP Tools Orchestrator Skill (v2.2.25)
|
|
14
14
|
|
|
15
15
|
Runtime guide for the **Konoha MCP Tools Orchestrator**, native Tree-sitter + FTS5 + Granite/MiniLM code-intelligence engine, and multi-agent coordination server.
|
|
16
16
|
|
|
@@ -22,7 +22,7 @@ verifiable rules exist. No rule here is invented.
|
|
|
22
22
|
3. `.omp/plans` must not be committed.
|
|
23
23
|
4. Official Konoha skills must match the actual codebase.
|
|
24
24
|
5. Manual documentation, diagrams, and asset review is mandatory.
|
|
25
|
-
6. Cross-platform compatibility across
|
|
25
|
+
6. Cross-platform compatibility across the 3 local CI legs must be verified as far as the host allows: (1) Linux (`pnpm test:sandbox [-- --shard=I/N]` Debian + `pnpm ci:act` / `pnpm ci:act:shard` Ubuntu `act`), (2) Windows (`docker/windows-vm/oem/run-ci.cmd [-Shard I/N]` / `retest.cmd` via `dockur/windows`), and (3) macOS — either a native/`macos-latest` run, Apple `container`, or a `dockur/macos` guest, or, on a host that cannot provide a macOS kernel, the documented symlinked-`HOME` proxy from `docs/CI.md`. Run `node scripts/sandbox_preflight.js` to see which legs this host can actually provide. A leg the host cannot provide must be reported as `proxy-verified` or `blocked` with its reason — never as a native pass. Only a GitHub `macos-latest` run at 4 GB or more closes the macOS leg natively.
|
|
26
26
|
7. Aislop gate: shipped code must pass `rtk npx aislop scan --changes` with score 100/100 Healthy, 0 errors, 0 warnings.
|
|
27
27
|
8. Maximum 700 lines per file/script (`.js`, `.py`, `.svelte`; enforced by `scripts/lint.js`).
|
|
28
28
|
9. The local dependency audit is mandatory after dependency changes: `rtk node tests/test_dependency_audit.js` (`pnpm audit --json` over the root and `apps/web` workspaces, no account or token). The Socket.dev scan is opt-in only (`pnpm audit:socket` with `SOCKET_CLI_API_TOKEN`) and never blocks CI.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 🍃 Konoha 9-Ninja Specialist Roster, Parallel Worktree Isolation & Operational Boundaries (v2.2.
|
|
1
|
+
# 🍃 Konoha 9-Ninja Specialist Roster, Parallel Worktree Isolation & Operational Boundaries (v2.2.25)
|
|
2
2
|
|
|
3
3
|
Technical reference on the 9-agent roster (`@sannin` router + 8 spawnable specialists), parallel git worktree contracts, strict tool permission matrices, compact skill loading (`use_skills`), and ADHD/anti-slop discipline.
|
|
4
4
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* src/url_canonical.js — URL canonicalization shared by web search and the
|
|
5
|
+
* Chunin knowledge store.
|
|
6
|
+
*
|
|
7
|
+
* Kept in its own module so `web_search.js` can dedupe without pulling in the
|
|
8
|
+
* database or the embedding pipeline.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Tracking parameters that never change which page is served.
|
|
12
|
+
const TRACKING_PARAM_RE = /^(utm_[a-z_]+|fbclid|gclid|mc_cid|mc_eid|ref|ref_src|source|igshid|yclid|_ga)$/i;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Canonicalizes a URL for dedupe: forces https, lowercases the host, drops
|
|
16
|
+
* tracking parameters, sorts the rest, and removes a trailing slash, an
|
|
17
|
+
* index page or a fragment. Two spellings of the same page collapse to one key.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} rawUrl
|
|
20
|
+
* @returns {string} canonical form, or '' when the input is not an http(s) URL
|
|
21
|
+
*/
|
|
22
|
+
function canonicalizeUrl(rawUrl) {
|
|
23
|
+
if (!rawUrl || typeof rawUrl !== 'string') return '';
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = new URL(rawUrl.trim());
|
|
27
|
+
} catch (_) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return '';
|
|
31
|
+
|
|
32
|
+
parsed.protocol = 'https:';
|
|
33
|
+
parsed.hostname = parsed.hostname.toLowerCase();
|
|
34
|
+
parsed.hash = '';
|
|
35
|
+
|
|
36
|
+
const keep = [];
|
|
37
|
+
for (const [key, value] of parsed.searchParams.entries()) {
|
|
38
|
+
if (TRACKING_PARAM_RE.test(key)) continue;
|
|
39
|
+
keep.push([key, value]);
|
|
40
|
+
}
|
|
41
|
+
keep.sort((a, b) => (a[0] === b[0] ? a[1].localeCompare(b[1]) : a[0].localeCompare(b[0])));
|
|
42
|
+
parsed.search = '';
|
|
43
|
+
for (const [key, value] of keep) parsed.searchParams.append(key, value);
|
|
44
|
+
|
|
45
|
+
let out = parsed.toString();
|
|
46
|
+
// 'https://a.com' renders as 'https://a.com/'. Strip a trailing slash from a
|
|
47
|
+
// non-root path whether or not a query is present, so '/a/?b=2' and '/a?b=2'
|
|
48
|
+
// are the same page.
|
|
49
|
+
if (parsed.pathname && parsed.pathname !== '/' && parsed.pathname.endsWith('/')) {
|
|
50
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, '');
|
|
51
|
+
out = parsed.toString();
|
|
52
|
+
}
|
|
53
|
+
if (parsed.pathname === '/' && !parsed.search) out = out.replace(/\/$/, '');
|
|
54
|
+
out = out.replace(/\/index\.html?$/i, '');
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = { canonicalizeUrl, TRACKING_PARAM_RE };
|
package/src/vector_pipeline.js
CHANGED
|
@@ -17,10 +17,12 @@ const SEMANTIC_SEARCH_ENV = 'KONOHA_SEMANTIC_SEARCH';
|
|
|
17
17
|
const EMBED_MODEL_REPO = 'onnx-community/granite-embedding-97m-multilingual-r2-ONNX';
|
|
18
18
|
const RERANK_MODEL_REPO = 'Xenova/ms-marco-MiniLM-L-6-v2';
|
|
19
19
|
const EMBED_DIM = 384;
|
|
20
|
-
// One sequence per ONNX call
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
20
|
+
// One sequence per ONNX call wins once padding is real: on a heterogeneous mix
|
|
21
|
+
// (40..1600 char chunks, 48 texts, best of 3) batch 1 measured 817 ms against 866
|
|
22
|
+
// ms at 4 and 941 ms at 16, because padding to the longest sequence in each batch
|
|
23
|
+
// costs more than the dispatch it saves. A homogeneous corpus hides this (batch 4
|
|
24
|
+
// then looks ~1.5x faster), which is why the default stays at 1. Callers with
|
|
25
|
+
// near-uniform widths can still raise it via `batchSize`.
|
|
24
26
|
const DEFAULT_EMBED_BATCH_SIZE = 1;
|
|
25
27
|
const DEFAULT_RERANK_BATCH_SIZE = 16;
|
|
26
28
|
const DEFAULT_EMBED_MAX_LENGTH = 512;
|
package/src/vector_search.js
CHANGED
|
@@ -10,7 +10,6 @@ const { getConfigValue } = require('./config_access');
|
|
|
10
10
|
/** Retrieval widths. Overridable so a large skill set can widen recall without a source edit. */
|
|
11
11
|
const SKILL_TOP_K = getConfigValue('skill_top_k');
|
|
12
12
|
const SKILL_CANDIDATE_K = getConfigValue('skill_candidate_k');
|
|
13
|
-
const SEMANTIC_TOP_K = getConfigValue('semantic_top_k');
|
|
14
13
|
|
|
15
14
|
const {
|
|
16
15
|
VECTOR_DIMENSION,
|
|
@@ -492,7 +491,10 @@ function populateHybridSkillResults(conn, topCandidates) {
|
|
|
492
491
|
}
|
|
493
492
|
|
|
494
493
|
async function findSkillHybrid(conn, query, options = {}) {
|
|
495
|
-
|
|
494
|
+
// A skill search is bounded by the skill width, not the semantic one: falling
|
|
495
|
+
// back to SEMANTIC_TOP_K (10) let the hybrid path return twice the top-5 the
|
|
496
|
+
// skill contract guarantees whenever a caller passed no topK.
|
|
497
|
+
const topK = options.topK || options.limit || Number(SKILL_TOP_K) || 5;
|
|
496
498
|
const candidateK = options.candidateK || 30;
|
|
497
499
|
if (!query || !query.trim()) return loadAllSkillsBrief(conn, topK);
|
|
498
500
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|