yandecode 0.1.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/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +9 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +19 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hook.d.ts +2 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +23 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/index-cmd.d.ts +2 -0
- package/dist/commands/index-cmd.d.ts.map +1 -0
- package/dist/commands/index-cmd.js +47 -0
- package/dist/commands/index-cmd.js.map +1 -0
- package/dist/commands/index.d.ts +13 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +15 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +22 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +71 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/rag.d.ts +2 -0
- package/dist/commands/rag.d.ts.map +1 -0
- package/dist/commands/rag.js +27 -0
- package/dist/commands/rag.js.map +1 -0
- package/dist/commands/start.d.ts +6 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +76 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +29 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/statusline.d.ts +2 -0
- package/dist/commands/statusline.d.ts.map +1 -0
- package/dist/commands/statusline.js +90 -0
- package/dist/commands/statusline.js.map +1 -0
- package/dist/commands/swarm.d.ts +4 -0
- package/dist/commands/swarm.d.ts.map +1 -0
- package/dist/commands/swarm.js +48 -0
- package/dist/commands/swarm.js.map +1 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +16 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/context.d.ts +13 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +31 -0
- package/dist/context.js.map +1 -0
- package/dist/doctor/checks.d.ts +18 -0
- package/dist/doctor/checks.d.ts.map +1 -0
- package/dist/doctor/checks.js +269 -0
- package/dist/doctor/checks.js.map +1 -0
- package/dist/hooks/handlers.d.ts +21 -0
- package/dist/hooks/handlers.d.ts.map +1 -0
- package/dist/hooks/handlers.js +191 -0
- package/dist/hooks/handlers.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/claude-md.d.ts +6 -0
- package/dist/integration/claude-md.d.ts.map +1 -0
- package/dist/integration/claude-md.js +30 -0
- package/dist/integration/claude-md.js.map +1 -0
- package/dist/integration/gitignore.d.ts +3 -0
- package/dist/integration/gitignore.d.ts.map +1 -0
- package/dist/integration/gitignore.js +13 -0
- package/dist/integration/gitignore.js.map +1 -0
- package/dist/integration/init.d.ts +17 -0
- package/dist/integration/init.d.ts.map +1 -0
- package/dist/integration/init.js +86 -0
- package/dist/integration/init.js.map +1 -0
- package/dist/integration/json-utils.d.ts +13 -0
- package/dist/integration/json-utils.d.ts.map +1 -0
- package/dist/integration/json-utils.js +33 -0
- package/dist/integration/json-utils.js.map +1 -0
- package/dist/integration/manifest.d.ts +17 -0
- package/dist/integration/manifest.d.ts.map +1 -0
- package/dist/integration/manifest.js +26 -0
- package/dist/integration/manifest.js.map +1 -0
- package/dist/integration/materialize.d.ts +9 -0
- package/dist/integration/materialize.d.ts.map +1 -0
- package/dist/integration/materialize.js +21 -0
- package/dist/integration/materialize.js.map +1 -0
- package/dist/integration/mcp-config.d.ts +4 -0
- package/dist/integration/mcp-config.d.ts.map +1 -0
- package/dist/integration/mcp-config.js +11 -0
- package/dist/integration/mcp-config.js.map +1 -0
- package/dist/integration/settings.d.ts +7 -0
- package/dist/integration/settings.d.ts.map +1 -0
- package/dist/integration/settings.js +70 -0
- package/dist/integration/settings.js.map +1 -0
- package/dist/integration/uninstall.d.ts +10 -0
- package/dist/integration/uninstall.d.ts.map +1 -0
- package/dist/integration/uninstall.js +71 -0
- package/dist/integration/uninstall.js.map +1 -0
- package/dist/launcher.d.ts +8 -0
- package/dist/launcher.d.ts.map +1 -0
- package/dist/launcher.js +18 -0
- package/dist/launcher.js.map +1 -0
- package/dist/mcp/server.d.ts +27 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +311 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/plugin-content.d.ts +21 -0
- package/dist/plugin-content.d.ts.map +1 -0
- package/dist/plugin-content.js +67 -0
- package/dist/plugin-content.js.map +1 -0
- package/dist/rag/format.d.ts +3 -0
- package/dist/rag/format.d.ts.map +1 -0
- package/dist/rag/format.js +12 -0
- package/dist/rag/format.js.map +1 -0
- package/dist/retrieval-runtime.d.ts +21 -0
- package/dist/retrieval-runtime.d.ts.map +1 -0
- package/dist/retrieval-runtime.js +47 -0
- package/dist/retrieval-runtime.js.map +1 -0
- package/dist/status-line/git.d.ts +3 -0
- package/dist/status-line/git.d.ts.map +1 -0
- package/dist/status-line/git.js +34 -0
- package/dist/status-line/git.js.map +1 -0
- package/dist/status-line/render.d.ts +29 -0
- package/dist/status-line/render.d.ts.map +1 -0
- package/dist/status-line/render.js +72 -0
- package/dist/status-line/render.js.map +1 -0
- package/dist/swarm-runtime.d.ts +11 -0
- package/dist/swarm-runtime.d.ts.map +1 -0
- package/dist/swarm-runtime.js +76 -0
- package/dist/swarm-runtime.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { YandeCodeError } from '@yandecode/core';
|
|
4
|
+
import { pluginRoot } from '@yandecode/plugin';
|
|
5
|
+
export const AGENT_NAMES = [
|
|
6
|
+
'yandecode-dispatcher',
|
|
7
|
+
'yandecode-scout',
|
|
8
|
+
'yandecode-implementer',
|
|
9
|
+
'yandecode-tester',
|
|
10
|
+
'yandecode-reviewer',
|
|
11
|
+
'yandecode-security',
|
|
12
|
+
'yandecode-researcher',
|
|
13
|
+
];
|
|
14
|
+
export const SKILL_NAMES = [
|
|
15
|
+
'yandecode-context-rules',
|
|
16
|
+
'yandecode-delegation',
|
|
17
|
+
'yandecode-swarm-protocol',
|
|
18
|
+
'yandecode-worker-contract',
|
|
19
|
+
];
|
|
20
|
+
export const HOOK_EVENTS = [
|
|
21
|
+
'SessionStart',
|
|
22
|
+
'PostToolUse',
|
|
23
|
+
'SessionEnd',
|
|
24
|
+
'SubagentStop',
|
|
25
|
+
'WorktreeCreate',
|
|
26
|
+
'WorktreeRemove',
|
|
27
|
+
];
|
|
28
|
+
export function loadPluginContent(root = pluginRoot) {
|
|
29
|
+
const content = {
|
|
30
|
+
root,
|
|
31
|
+
agents: AGENT_NAMES.map((name) => ({ name, file: join(root, 'agents', `${name}.md`) })),
|
|
32
|
+
skills: SKILL_NAMES.map((name) => ({
|
|
33
|
+
name,
|
|
34
|
+
dir: join(root, 'skills', name),
|
|
35
|
+
file: join(root, 'skills', name, 'SKILL.md'),
|
|
36
|
+
})),
|
|
37
|
+
hooksFile: join(root, 'hooks', 'hooks.json'),
|
|
38
|
+
mcpFile: join(root, '.mcp.json'),
|
|
39
|
+
manifestFile: join(root, '.claude-plugin', 'plugin.json'),
|
|
40
|
+
};
|
|
41
|
+
const required = [
|
|
42
|
+
...content.agents.map((a) => a.file),
|
|
43
|
+
...content.skills.map((s) => s.file),
|
|
44
|
+
content.hooksFile,
|
|
45
|
+
content.mcpFile,
|
|
46
|
+
content.manifestFile,
|
|
47
|
+
];
|
|
48
|
+
const missing = required.filter((f) => !existsSync(f));
|
|
49
|
+
if (missing.length > 0) {
|
|
50
|
+
throw new YandeCodeError('PLUGIN_CONTENT_MISSING', `missing plugin files: ${missing.join(', ')}`);
|
|
51
|
+
}
|
|
52
|
+
return content;
|
|
53
|
+
}
|
|
54
|
+
export function parseFrontmatter(markdown) {
|
|
55
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(markdown);
|
|
56
|
+
if (!match)
|
|
57
|
+
return {};
|
|
58
|
+
const out = {};
|
|
59
|
+
for (const line of match[1].split(/\r?\n/)) {
|
|
60
|
+
const idx = line.indexOf(':');
|
|
61
|
+
if (idx <= 0)
|
|
62
|
+
continue;
|
|
63
|
+
out[line.slice(0, idx).trim()] = line.slice(idx + 1).trim();
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=plugin-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-content.js","sourceRoot":"","sources":["../src/plugin-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,sBAAsB;IACtB,iBAAiB;IACjB,uBAAuB;IACvB,kBAAkB;IAClB,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;CACd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AG,MAAM,CAWtE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function formatRagResults(query, hits) {
|
|
2
|
+
if (hits.length === 0)
|
|
3
|
+
return `No results for "${query}"\n`;
|
|
4
|
+
const lines = [];
|
|
5
|
+
for (const hit of hits) {
|
|
6
|
+
lines.push(`${hit.path}:${hit.startLine}-${hit.endLine} [${hit.symbol ?? '-'}] score=${hit.score.toFixed(3)}`);
|
|
7
|
+
lines.push(hit.content.split('\n').slice(0, 3).join('\n'));
|
|
8
|
+
lines.push('');
|
|
9
|
+
}
|
|
10
|
+
return lines.join('\n');
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/rag/format.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,IAAc;IAC5D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,mBAAmB,KAAK,KAAK,CAAC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CACR,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,MAAM,IAAI,GAAG,WAAW,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CACnG,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DocumentRepository } from '@yandecode/core';
|
|
2
|
+
import { HybridRetriever, IndexingService, type EmbeddingProvider } from '@yandecode/retrieval';
|
|
3
|
+
import type { RuntimeContext } from './context.js';
|
|
4
|
+
export interface Retrieval {
|
|
5
|
+
provider: EmbeddingProvider;
|
|
6
|
+
documents: DocumentRepository;
|
|
7
|
+
indexing: IndexingService;
|
|
8
|
+
retriever: HybridRetriever;
|
|
9
|
+
dispose(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createProvider(rt: RuntimeContext): EmbeddingProvider;
|
|
12
|
+
/**
|
|
13
|
+
* `sharedProvider`, when passed, is reused instead of constructing a new one, and `dispose()`
|
|
14
|
+
* becomes a no-op for it - the caller owns its lifecycle. This lets a long-running process (the
|
|
15
|
+
* MCP server) hold one persistent EmbeddingProvider across many `createRetrieval` calls instead
|
|
16
|
+
* of tearing down and reconstructing the ONNX pipeline on every request, while everything else
|
|
17
|
+
* (documents/chunker/index/retriever) still gets rebuilt fresh each call so index freshness after
|
|
18
|
+
* a reindex is unaffected.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRetrieval(rt: RuntimeContext, sharedProvider?: EmbeddingProvider): Retrieval;
|
|
21
|
+
//# sourceMappingURL=retrieval-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-runtime.d.ts","sourceRoot":"","sources":["../src/retrieval-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAIL,eAAe,EACf,eAAe,EAGf,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,iBAAiB,CAMpE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,cAAc,EAAE,cAAc,CAAC,EAAE,iBAAiB,GAAG,SAAS,CA8BjG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DocumentRepository } from '@yandecode/core';
|
|
2
|
+
import { ArcticEmbedXsProvider, createDefaultChunker, HashEmbeddingProvider, HybridRetriever, IndexingService, resolveModelCacheDir, USearchVectorIndex, } from '@yandecode/retrieval';
|
|
3
|
+
export function createProvider(rt) {
|
|
4
|
+
if (process.env.YANDECODE_EMBEDDINGS === 'hash')
|
|
5
|
+
return new HashEmbeddingProvider(64);
|
|
6
|
+
return new ArcticEmbedXsProvider({
|
|
7
|
+
cacheDir: resolveModelCacheDir(process.env),
|
|
8
|
+
modelId: rt.config.rag.embeddingModel,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `sharedProvider`, when passed, is reused instead of constructing a new one, and `dispose()`
|
|
13
|
+
* becomes a no-op for it - the caller owns its lifecycle. This lets a long-running process (the
|
|
14
|
+
* MCP server) hold one persistent EmbeddingProvider across many `createRetrieval` calls instead
|
|
15
|
+
* of tearing down and reconstructing the ONNX pipeline on every request, while everything else
|
|
16
|
+
* (documents/chunker/index/retriever) still gets rebuilt fresh each call so index freshness after
|
|
17
|
+
* a reindex is unaffected.
|
|
18
|
+
*/
|
|
19
|
+
export function createRetrieval(rt, sharedProvider) {
|
|
20
|
+
const provider = sharedProvider ?? createProvider(rt);
|
|
21
|
+
const documents = new DocumentRepository(rt.state);
|
|
22
|
+
const chunker = createDefaultChunker(provider);
|
|
23
|
+
const openIndex = (file) => new USearchVectorIndex({ dimensions: provider.dimensions, file });
|
|
24
|
+
const indexing = new IndexingService({
|
|
25
|
+
root: rt.paths.root,
|
|
26
|
+
indexesDir: rt.paths.indexesDir,
|
|
27
|
+
documents,
|
|
28
|
+
indexRepo: rt.index,
|
|
29
|
+
provider,
|
|
30
|
+
chunker,
|
|
31
|
+
events: rt.events,
|
|
32
|
+
openIndex,
|
|
33
|
+
});
|
|
34
|
+
const meta = rt.index.getMeta('repository');
|
|
35
|
+
const index = openIndex(meta?.filePath ?? null);
|
|
36
|
+
if (meta?.filePath)
|
|
37
|
+
index.load();
|
|
38
|
+
const retriever = new HybridRetriever({ documents, provider, index });
|
|
39
|
+
return {
|
|
40
|
+
provider,
|
|
41
|
+
documents,
|
|
42
|
+
indexing,
|
|
43
|
+
retriever,
|
|
44
|
+
dispose: () => (sharedProvider ? Promise.resolve() : provider.dispose()),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=retrieval-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-runtime.js","sourceRoot":"","sources":["../src/retrieval-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAW9B,MAAM,UAAU,cAAc,CAAC,EAAkB;IAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM;QAAE,OAAO,IAAI,qBAAqB,CAAC,EAAE,CAAC,CAAC;IACtF,OAAO,IAAI,qBAAqB,CAAC;QAC/B,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC;QAC3C,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc;KACtC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;A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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/status-line/git.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAgBrD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAmBnE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
function run(args, cwd) {
|
|
3
|
+
try {
|
|
4
|
+
return execFileSync('git', args, {
|
|
5
|
+
cwd,
|
|
6
|
+
timeout: 1000,
|
|
7
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
8
|
+
})
|
|
9
|
+
.toString('utf8')
|
|
10
|
+
.trim();
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function gatherGitInfo(cwd) {
|
|
17
|
+
const branch = run(['branch', '--show-current'], cwd);
|
|
18
|
+
if (branch === null)
|
|
19
|
+
return null;
|
|
20
|
+
const statusOut = run(['status', '--porcelain'], cwd) ?? '';
|
|
21
|
+
const dirty = statusOut.length > 0;
|
|
22
|
+
let ahead = 0;
|
|
23
|
+
let behind = 0;
|
|
24
|
+
const counts = run(['rev-list', '--left-right', '--count', 'HEAD...@{u}'], cwd);
|
|
25
|
+
if (counts) {
|
|
26
|
+
const parts = counts.split(/\s+/);
|
|
27
|
+
const a = Number.parseInt(parts[0] ?? '', 10);
|
|
28
|
+
const b = Number.parseInt(parts[1] ?? '', 10);
|
|
29
|
+
ahead = Number.isFinite(a) ? a : 0;
|
|
30
|
+
behind = Number.isFinite(b) ? b : 0;
|
|
31
|
+
}
|
|
32
|
+
return { branch: branch || '(detached)', dirty, ahead, behind };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js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,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface StatusLineGitInfo {
|
|
2
|
+
branch: string;
|
|
3
|
+
dirty: boolean;
|
|
4
|
+
ahead: number;
|
|
5
|
+
behind: number;
|
|
6
|
+
}
|
|
7
|
+
export interface StatusLineSwarmInfo {
|
|
8
|
+
done: number;
|
|
9
|
+
total: number;
|
|
10
|
+
}
|
|
11
|
+
export interface StatusLineWorkspaceInfo {
|
|
12
|
+
chunks: number;
|
|
13
|
+
dirtyFiles: number;
|
|
14
|
+
indexGeneration: number;
|
|
15
|
+
indexBytes: number;
|
|
16
|
+
hooksRegistered: number;
|
|
17
|
+
hooksTotal: number;
|
|
18
|
+
swarm: StatusLineSwarmInfo | null;
|
|
19
|
+
}
|
|
20
|
+
export interface StatusLineInput {
|
|
21
|
+
version: string;
|
|
22
|
+
projectName: string;
|
|
23
|
+
model: string | null;
|
|
24
|
+
durationMs: number | null;
|
|
25
|
+
git: StatusLineGitInfo | null;
|
|
26
|
+
workspace: StatusLineWorkspaceInfo | null;
|
|
27
|
+
}
|
|
28
|
+
export declare function renderStatusLine(input: StatusLineInput): string;
|
|
29
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/status-line/render.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAC3C;AAqCD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CA0B/D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const RESET = '[0m';
|
|
2
|
+
const BOLD = '[1m';
|
|
3
|
+
const DIM = '[2m';
|
|
4
|
+
const MAGENTA = '[35m';
|
|
5
|
+
const GREEN = '[32m';
|
|
6
|
+
const YELLOW = '[33m';
|
|
7
|
+
const CYAN = '[36m';
|
|
8
|
+
const RED = '[31m';
|
|
9
|
+
function formatDuration(ms) {
|
|
10
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
11
|
+
if (totalSeconds < 60)
|
|
12
|
+
return `${totalSeconds}s`;
|
|
13
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
14
|
+
const seconds = totalSeconds % 60;
|
|
15
|
+
if (minutes < 60)
|
|
16
|
+
return `${minutes}m${seconds}s`;
|
|
17
|
+
const hours = Math.floor(minutes / 60);
|
|
18
|
+
return `${hours}h${minutes % 60}m`;
|
|
19
|
+
}
|
|
20
|
+
function formatBytes(bytes) {
|
|
21
|
+
const mb = bytes / (1024 * 1024);
|
|
22
|
+
if (mb < 0.1 && bytes > 0)
|
|
23
|
+
return '<0.1MB';
|
|
24
|
+
return `${mb.toFixed(mb < 10 ? 1 : 0)}MB`;
|
|
25
|
+
}
|
|
26
|
+
function renderGitSegment(git) {
|
|
27
|
+
const dirtyFlag = git.dirty ? `${YELLOW}*${RESET}` : '';
|
|
28
|
+
const parts = [`${BOLD}${git.branch}${RESET}${dirtyFlag}`];
|
|
29
|
+
if (git.ahead > 0)
|
|
30
|
+
parts.push(`${GREEN}+${git.ahead}${RESET}`);
|
|
31
|
+
if (git.behind > 0)
|
|
32
|
+
parts.push(`${RED}-${git.behind}${RESET}`);
|
|
33
|
+
return parts.join(' ');
|
|
34
|
+
}
|
|
35
|
+
function renderScanSegment(ws) {
|
|
36
|
+
if (ws.chunks === 0)
|
|
37
|
+
return `${RED}○ not indexed${RESET}`;
|
|
38
|
+
if (ws.dirtyFiles > 0)
|
|
39
|
+
return `${YELLOW}◐ scan pending (${ws.dirtyFiles})${RESET}`;
|
|
40
|
+
return `${GREEN}● scan clean${RESET}`;
|
|
41
|
+
}
|
|
42
|
+
function renderSwarmSegment(ws) {
|
|
43
|
+
if (!ws.swarm)
|
|
44
|
+
return `${DIM}Swarm ○ idle${RESET}`;
|
|
45
|
+
return `Swarm ${CYAN}●${RESET} ${ws.swarm.done}/${ws.swarm.total}`;
|
|
46
|
+
}
|
|
47
|
+
export function renderStatusLine(input) {
|
|
48
|
+
const headParts = [`${MAGENTA}●${RESET} ${BOLD}YandeCode${RESET} v${input.version}`];
|
|
49
|
+
headParts.push(`${DIM}${input.projectName}${RESET}`);
|
|
50
|
+
if (input.git)
|
|
51
|
+
headParts.push(renderGitSegment(input.git));
|
|
52
|
+
if (input.model)
|
|
53
|
+
headParts.push(`${CYAN}${input.model}${RESET}`);
|
|
54
|
+
if (input.durationMs !== null)
|
|
55
|
+
headParts.push(`${DIM}⏱${formatDuration(input.durationMs)}${RESET}`);
|
|
56
|
+
const line1 = headParts.join(` ${DIM}|${RESET} `);
|
|
57
|
+
if (!input.workspace) {
|
|
58
|
+
return `${line1}\n${DIM}yandecode: not initialized here · run "yandecode init"${RESET}`;
|
|
59
|
+
}
|
|
60
|
+
const ws = input.workspace;
|
|
61
|
+
const line2Parts = [
|
|
62
|
+
renderSwarmSegment(ws),
|
|
63
|
+
`Hooks ${ws.hooksRegistered}/${ws.hooksTotal}`,
|
|
64
|
+
`📚 ${ws.chunks} chunks`,
|
|
65
|
+
`💾 ${formatBytes(ws.indexBytes)}`,
|
|
66
|
+
renderScanSegment(ws),
|
|
67
|
+
];
|
|
68
|
+
const line2 = line2Parts.join(` ${DIM}·${RESET} `);
|
|
69
|
+
const line3 = `${DIM}💡 rag_search finds code before you read it manually · github.com/whoisclebs/yandecode${RESET}`;
|
|
70
|
+
return `${line1}\n${line2}\n${line3}`;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/status-line/render.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,OAAO,GAAG,OAAO,CAAC;AACxB,MAAM,KAAK,GAAG,OAAO,CAAC;AACtB,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,MAAM,IAAI,GAAG,OAAO,CAAC;AACrB,MAAM,GAAG,GAAG,OAAO,CAAC;AAiCpB,SAAS,cAAc,CAAC,EAAU;IAChC,MAAM,YAAY,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,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;QAC3B,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;IAEpD,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,GAAG,KAAK,KAAK,GAAG,yDAAyD,KAAK,EAAE,CAAC;IAC1F,CAAC;IAED,MAAM,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,UAAU,GAAG;QACjB,kBAAkB,CAAC,EAAE,CAAC;QACtB,SAAS,EAAE,CAAC,eAAe,IAAI,EAAE,CAAC,UAAU,EAAE;QAC9C,MAAM,EAAE,CAAC,MAAM,SAAS;QACxB,MAAM,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE;QAClC,iBAAiB,CAAC,EAAE,CAAC;KACtB,CAAC;IACF,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;IAErD,MAAM,KAAK,GAAG,GAAG,GAAG,yFAAyF,KAAK,EAAE,CAAC;IAErH,OAAO,GAAG,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MessageRepository } from '@yandecode/core';
|
|
2
|
+
import { MemoryRetriever, MemoryService, SwarmService } from '@yandecode/swarm';
|
|
3
|
+
import type { RuntimeContext } from './context.js';
|
|
4
|
+
export interface SwarmRuntime {
|
|
5
|
+
swarmService: SwarmService;
|
|
6
|
+
messages: MessageRepository;
|
|
7
|
+
memoryService: MemoryService;
|
|
8
|
+
memoryRetriever: MemoryRetriever;
|
|
9
|
+
}
|
|
10
|
+
export declare function createSwarmRuntime(rt: RuntimeContext): Promise<SwarmRuntime>;
|
|
11
|
+
//# sourceMappingURL=swarm-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-runtime.d.ts","sourceRoot":"","sources":["../src/swarm-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,iBAAiB,EAKlB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,eAAe,CAAC;CAClC;AAOD,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAqElF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { mkdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { LeaseRepository, MemoryRepository, MessageRepository, SwarmRepository, TaskRepository, WorkspaceRepository, nowIso, } from '@yandecode/core';
|
|
4
|
+
import { ArcticEmbedXsProvider, generationFileName, HashEmbeddingProvider, resolveModelCacheDir, USearchVectorIndex, } from '@yandecode/retrieval';
|
|
5
|
+
import { MemoryRetriever, MemoryService, SwarmService } from '@yandecode/swarm';
|
|
6
|
+
function createMemoryProvider() {
|
|
7
|
+
if (process.env.YANDECODE_EMBEDDINGS === 'hash')
|
|
8
|
+
return new HashEmbeddingProvider(64);
|
|
9
|
+
return new ArcticEmbedXsProvider({ cacheDir: resolveModelCacheDir(process.env) });
|
|
10
|
+
}
|
|
11
|
+
export async function createSwarmRuntime(rt) {
|
|
12
|
+
const swarmService = new SwarmService({
|
|
13
|
+
swarms: new SwarmRepository(rt.state),
|
|
14
|
+
tasks: new TaskRepository(rt.state),
|
|
15
|
+
leases: new LeaseRepository(rt.state),
|
|
16
|
+
workspaces: new WorkspaceRepository(rt.state),
|
|
17
|
+
});
|
|
18
|
+
mkdirSync(rt.paths.indexesDir, { recursive: true });
|
|
19
|
+
const provider = createMemoryProvider();
|
|
20
|
+
const memories = new MemoryRepository(rt.state);
|
|
21
|
+
const meta = rt.index.getMeta('memory');
|
|
22
|
+
const file = meta?.filePath ?? join(rt.paths.indexesDir, generationFileName('memory', 1));
|
|
23
|
+
const index = new USearchVectorIndex({ dimensions: provider.dimensions, file });
|
|
24
|
+
if (meta?.filePath) {
|
|
25
|
+
index.load();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Awaited (not fire-and-forget): StateService.write() queues this write and only attaches
|
|
29
|
+
// its rejection handler to a *derived* promise, so a void-ed call here would both risk an
|
|
30
|
+
// unhandled rejection and let a short-lived CLI process (e.g. a single hook invocation)
|
|
31
|
+
// exit before the write actually lands, silently dropping the very first 'memory' index
|
|
32
|
+
// meta row.
|
|
33
|
+
await rt.index.setMeta({
|
|
34
|
+
name: 'memory',
|
|
35
|
+
generation: 1,
|
|
36
|
+
dimensions: provider.dimensions,
|
|
37
|
+
modelId: provider.modelId,
|
|
38
|
+
vectorCount: 0,
|
|
39
|
+
builtAt: nowIso(),
|
|
40
|
+
filePath: file,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// Defends against a missing, corrupt, or stale-empty on-disk index: if what actually loaded
|
|
44
|
+
// doesn't match the memories table (the real source of truth for embeddings, per ADR-007), the
|
|
45
|
+
// next memory_store's index.save() would otherwise atomically overwrite the good on-disk file
|
|
46
|
+
// with an incomplete one. Rebuilding from iterateEmbeddings() is the same recovery IndexingService
|
|
47
|
+
// already provides for the repository index's 'rebuild-vectors' mode.
|
|
48
|
+
//
|
|
49
|
+
// Known gap: this check is size-only, not dimensions/modelId-aware. If the embedding provider
|
|
50
|
+
// changes (e.g. toggling YANDECODE_EMBEDDINGS=hash, or a future config change to
|
|
51
|
+
// rag.embeddingModel), the on-disk index and the stored embeddings in `memories.embedding` were
|
|
52
|
+
// both built with the OLD provider's dimensionality - a same-size rebuild here would hand
|
|
53
|
+
// wrong-dimension vectors to a VectorIndex constructed for the NEW dimensions. Detecting a
|
|
54
|
+
// provider switch is straightforward (compare provider.dimensions/modelId against the persisted
|
|
55
|
+
// vector_index_meta row), but a correct recovery requires RE-EMBEDDING every stored memory with
|
|
56
|
+
// the new provider, not just rebuilding the index shell from already-stored, now-incompatible
|
|
57
|
+
// vectors - that's a real feature (a memory re-embedding migration), not a safe one-line fix, so
|
|
58
|
+
// it's deliberately not attempted here. v0 does not support switching embedding providers for an
|
|
59
|
+
// existing memory store.
|
|
60
|
+
if (index.stats().size !== memories.count()) {
|
|
61
|
+
index.rebuild((function* rebuildRecords() {
|
|
62
|
+
for (const { vectorId, embedding } of memories.iterateEmbeddings()) {
|
|
63
|
+
yield { id: vectorId, vector: embedding };
|
|
64
|
+
}
|
|
65
|
+
})());
|
|
66
|
+
}
|
|
67
|
+
const memoryService = new MemoryService({ memories, provider, index });
|
|
68
|
+
const memoryRetriever = new MemoryRetriever({ memories, provider, index });
|
|
69
|
+
return {
|
|
70
|
+
swarmService,
|
|
71
|
+
messages: new MessageRepository(rt.state),
|
|
72
|
+
memoryService,
|
|
73
|
+
memoryRetriever,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=swarm-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-runtime.js","sourceRoot":"","sources":["../src/swarm-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,MAAM,GACP,MAAM,iBAAiB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AI,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAE3E,OAAO;QACL,YAAY;QACZ,QAAQ,EAAE,IAAI,iBAAiB,CAAC,EAAE,CAAC,KAAK,CAAC;QACzC,aAAa;QACb,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,OAAO,GAAW,GAAG,CAAC,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yandecode",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "YandeCode CLI — local-first agent harness for Claude Code",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"yandecode": "./dist/bin.js"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/whoisclebs/yandecode.git",
|
|
27
|
+
"directory": "packages/cli"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/whoisclebs/yandecode",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -b",
|
|
32
|
+
"typecheck": "tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
36
|
+
"@yandecode/core": "0.1.0",
|
|
37
|
+
"@yandecode/plugin": "0.1.0",
|
|
38
|
+
"@yandecode/retrieval": "0.1.0",
|
|
39
|
+
"@yandecode/swarm": "0.1.0",
|
|
40
|
+
"commander": "^15.0.0",
|
|
41
|
+
"zod": "^4.6.5"
|
|
42
|
+
}
|
|
43
|
+
}
|