@agentskit/doc-bridge 0.1.0-alpha.1 → 0.1.0-alpha.3
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/CHANGELOG.md +28 -0
- package/README.md +1 -1
- package/dist/cli/program.js +416 -148
- package/dist/cli/program.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/{index-CD_zmKXf.d.ts → index-CPUJbTbg.d.ts} +19 -10
- package/dist/index.d.ts +25 -6
- package/dist/index.js +398 -132
- package/dist/index.js.map +1 -1
- package/docs/DOGFOOD-ROUND2.md +142 -0
- package/docs/DOGFOOD.md +92 -0
- package/package.json +32 -14
- package/scripts/prepare.mjs +44 -0
- package/src/cli/program.ts +947 -0
- package/src/config/defaults.ts +63 -0
- package/src/config/define-config.ts +6 -0
- package/src/config/index.ts +15 -0
- package/src/config/load-config.ts +138 -0
- package/src/config/schema.ts +294 -0
- package/src/federation/llms.ts +154 -0
- package/src/gates/run-gates.ts +274 -0
- package/src/index-builder/build-handoffs.ts +232 -0
- package/src/index-builder/build-index.ts +137 -0
- package/src/index-builder/capabilities.ts +37 -0
- package/src/index-builder/content-hash.ts +19 -0
- package/src/index-builder/human-adapters/core.ts +100 -0
- package/src/index-builder/human-adapters/docusaurus.ts +113 -0
- package/src/index-builder/human-adapters/fumadocs.ts +70 -0
- package/src/index-builder/human-adapters/index.ts +52 -0
- package/src/index-builder/human-adapters/plain-markdown.ts +10 -0
- package/src/index-builder/llms-txt.ts +19 -0
- package/src/index-builder/plugins/human-markdown.ts +7 -0
- package/src/index-builder/plugins/pnpm-monorepo.ts +72 -0
- package/src/index-builder/scan-corpus.ts +185 -0
- package/src/index.ts +120 -0
- package/src/intelligence/adapter.ts +90 -0
- package/src/intelligence/chat.ts +148 -0
- package/src/intelligence/peers.ts +59 -0
- package/src/intelligence/rag.ts +98 -0
- package/src/lib/glob-expand.ts +33 -0
- package/src/lib/markdown.ts +117 -0
- package/src/lib/package-manager.ts +104 -0
- package/src/lib/paths.ts +6 -0
- package/src/lib/walk.ts +45 -0
- package/src/mcp/server.ts +276 -0
- package/src/memory/ingest.ts +51 -0
- package/src/memory/pipeline.ts +119 -0
- package/src/query/load-index.ts +25 -0
- package/src/query/query.ts +142 -0
- package/src/query/search.ts +126 -0
- package/src/retriever/doc-bridge-retriever.ts +62 -0
- package/src/schemas/agent-handoff.ts +82 -0
- package/src/schemas/doc-bridge-index.ts +108 -0
- package/src/schemas/json-schemas.ts +157 -0
- package/src/schemas/memory-candidate.ts +37 -0
- package/src/shims/agentskit-peers.d.ts +80 -0
- package/src/validate.ts +67 -0
- package/src/version.ts +1 -0
- package/tsconfig.json +21 -0
- package/tsup.config.ts +15 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const MEMORY_CANDIDATE_SCHEMA_VERSION = 1 as const
|
|
4
|
+
|
|
5
|
+
export const MemorySourceSchema = z.enum([
|
|
6
|
+
'cursor',
|
|
7
|
+
'claude',
|
|
8
|
+
'codex',
|
|
9
|
+
'copilot',
|
|
10
|
+
'agent-memory',
|
|
11
|
+
'manual',
|
|
12
|
+
])
|
|
13
|
+
|
|
14
|
+
export const MemorySuggestedTypeSchema = z.enum([
|
|
15
|
+
'user',
|
|
16
|
+
'feedback',
|
|
17
|
+
'project',
|
|
18
|
+
'reference',
|
|
19
|
+
'unknown',
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
export const MemoryCandidateV1Schema = z
|
|
23
|
+
.object({
|
|
24
|
+
schemaVersion: z.literal(MEMORY_CANDIDATE_SCHEMA_VERSION),
|
|
25
|
+
id: z.string().min(1).max(256),
|
|
26
|
+
source: MemorySourceSchema,
|
|
27
|
+
rawPath: z.string().min(1).max(512).optional(),
|
|
28
|
+
fact: z.string().min(1).max(8_000),
|
|
29
|
+
why: z.string().max(4_000).optional(),
|
|
30
|
+
howToApply: z.string().max(4_000).optional(),
|
|
31
|
+
suggestedType: MemorySuggestedTypeSchema,
|
|
32
|
+
confidence: z.number().min(0).max(1),
|
|
33
|
+
references: z.array(z.string().min(1).max(512)).max(64),
|
|
34
|
+
})
|
|
35
|
+
.strict()
|
|
36
|
+
|
|
37
|
+
export type MemoryCandidateV1 = z.infer<typeof MemoryCandidateV1Schema>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Ambient types for optional Layer-1 peers (not installed with Layer 0). */
|
|
2
|
+
|
|
3
|
+
declare module '@agentskit/rag' {
|
|
4
|
+
export type InputDocument = {
|
|
5
|
+
id?: string
|
|
6
|
+
content: string
|
|
7
|
+
source?: string
|
|
8
|
+
metadata?: Record<string, unknown>
|
|
9
|
+
}
|
|
10
|
+
export type RAG = {
|
|
11
|
+
ingest: (documents: InputDocument[]) => Promise<void>
|
|
12
|
+
search: (
|
|
13
|
+
query: string,
|
|
14
|
+
options?: { topK?: number; threshold?: number },
|
|
15
|
+
) => Promise<
|
|
16
|
+
ReadonlyArray<{
|
|
17
|
+
id?: string
|
|
18
|
+
content: string
|
|
19
|
+
score?: number
|
|
20
|
+
metadata?: Record<string, unknown>
|
|
21
|
+
source?: string
|
|
22
|
+
}>
|
|
23
|
+
>
|
|
24
|
+
retrieve: (request: { query: string }) => Promise<unknown[]>
|
|
25
|
+
}
|
|
26
|
+
export function createRAG(config: {
|
|
27
|
+
embed: unknown
|
|
28
|
+
store: unknown
|
|
29
|
+
chunkSize?: number
|
|
30
|
+
chunkOverlap?: number
|
|
31
|
+
topK?: number
|
|
32
|
+
}): RAG
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module '@agentskit/memory' {
|
|
36
|
+
export function fileVectorMemory(options: { path: string }): unknown
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '@agentskit/adapters' {
|
|
40
|
+
export function ollama(options: { model?: string; baseUrl?: string }): unknown
|
|
41
|
+
export function openai(options: { apiKey: string; model?: string; baseUrl?: string }): unknown
|
|
42
|
+
export function anthropic(options: { apiKey: string; model?: string }): unknown
|
|
43
|
+
export function openrouter(options: { apiKey: string; model?: string }): unknown
|
|
44
|
+
export function ollamaEmbedder(options?: { model?: string; baseUrl?: string }): unknown
|
|
45
|
+
export function openaiEmbedder(options: { apiKey: string; model?: string }): unknown
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module '@agentskit/core' {
|
|
49
|
+
export function createChatController(config: Record<string, unknown>): {
|
|
50
|
+
send: (input: string) => Promise<{ content?: string; messages?: unknown[] }>
|
|
51
|
+
messages?: unknown[]
|
|
52
|
+
}
|
|
53
|
+
export function formatRetrievedDocuments(docs: unknown[]): string
|
|
54
|
+
export function createStaticRetriever(docs: unknown[]): unknown
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare module '@agentskit/ink' {
|
|
58
|
+
export function useChat(config: Record<string, unknown>): {
|
|
59
|
+
messages: ReadonlyArray<{ id: string; role: string; content: string }>
|
|
60
|
+
send: (input: string) => Promise<void>
|
|
61
|
+
isStreaming?: boolean
|
|
62
|
+
}
|
|
63
|
+
export const ChatContainer: unknown
|
|
64
|
+
export const Message: unknown
|
|
65
|
+
export const InputBar: unknown
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module 'ink' {
|
|
69
|
+
export function render(node: unknown): { unmount: () => void; waitUntilExit: () => Promise<void> }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare module 'react' {
|
|
73
|
+
export function createElement(
|
|
74
|
+
type: unknown,
|
|
75
|
+
props?: Record<string, unknown> | null,
|
|
76
|
+
...children: unknown[]
|
|
77
|
+
): unknown
|
|
78
|
+
const React: { createElement: typeof createElement }
|
|
79
|
+
export default React
|
|
80
|
+
}
|
package/src/validate.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ZodError } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { DocBridgeConfigV1Schema, type DocBridgeConfigV1 } from './config/schema.js'
|
|
4
|
+
import {
|
|
5
|
+
AgentHandoffLegacySchema,
|
|
6
|
+
AgentHandoffV1Schema,
|
|
7
|
+
AgentSearchV1Schema,
|
|
8
|
+
normalizeAgentHandoff,
|
|
9
|
+
type AgentHandoffV1,
|
|
10
|
+
type AgentSearchV1,
|
|
11
|
+
} from './schemas/agent-handoff.js'
|
|
12
|
+
import { DocBridgeIndexV1Schema, type DocBridgeIndexV1 } from './schemas/doc-bridge-index.js'
|
|
13
|
+
import {
|
|
14
|
+
MemoryCandidateV1Schema,
|
|
15
|
+
type MemoryCandidateV1,
|
|
16
|
+
} from './schemas/memory-candidate.js'
|
|
17
|
+
|
|
18
|
+
export type ParseIssue = {
|
|
19
|
+
readonly path: string
|
|
20
|
+
readonly message: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ParseResult<T> =
|
|
24
|
+
| { readonly ok: true; readonly value: T }
|
|
25
|
+
| { readonly ok: false; readonly issues: readonly ParseIssue[] }
|
|
26
|
+
|
|
27
|
+
const zodIssues = (error: ZodError): readonly ParseIssue[] =>
|
|
28
|
+
error.issues.map((issue) => ({
|
|
29
|
+
path: issue.path.join('.') || '(root)',
|
|
30
|
+
message: issue.message,
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
export const safeParseAgentHandoff = (input: unknown): ParseResult<AgentHandoffV1> => {
|
|
34
|
+
const legacy = AgentHandoffLegacySchema.safeParse(input)
|
|
35
|
+
if (!legacy.success) return { ok: false, issues: zodIssues(legacy.error) }
|
|
36
|
+
const normalized = AgentHandoffV1Schema.safeParse(normalizeAgentHandoff(legacy.data))
|
|
37
|
+
if (!normalized.success) return { ok: false, issues: zodIssues(normalized.error) }
|
|
38
|
+
return { ok: true, value: normalized.data }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const parseAgentHandoff = (input: unknown): AgentHandoffV1 => {
|
|
42
|
+
const result = safeParseAgentHandoff(input)
|
|
43
|
+
if (!result.ok) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Invalid AgentHandoff:\n${result.issues.map((i) => ` - ${i.path}: ${i.message}`).join('\n')}`,
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return result.value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const parseAgentSearch = (input: unknown): AgentSearchV1 => AgentSearchV1Schema.parse(input)
|
|
52
|
+
|
|
53
|
+
export const parseDocBridgeIndex = (input: unknown): DocBridgeIndexV1 =>
|
|
54
|
+
DocBridgeIndexV1Schema.parse(input)
|
|
55
|
+
|
|
56
|
+
export const parseMemoryCandidate = (input: unknown): MemoryCandidateV1 =>
|
|
57
|
+
MemoryCandidateV1Schema.parse(input)
|
|
58
|
+
|
|
59
|
+
export const parseDocBridgeConfig = (input: unknown): DocBridgeConfigV1 => {
|
|
60
|
+
const result = DocBridgeConfigV1Schema.safeParse(input)
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Invalid doc-bridge config:\n${zodIssues(result.error).map((i) => ` - ${i.path}: ${i.message}`).join('\n')}`,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
return result.data
|
|
67
|
+
}
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PACKAGE_VERSION = '0.1.0-alpha.3'
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUncheckedIndexedAccess": true,
|
|
10
|
+
"exactOptionalPropertyTypes": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"ignoreDeprecations": "6.0",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"rootDir": "src"
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*.ts"],
|
|
20
|
+
"exclude": ["node_modules", "dist"]
|
|
21
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: {
|
|
5
|
+
index: 'src/index.ts',
|
|
6
|
+
'config/index': 'src/config/index.ts',
|
|
7
|
+
'cli/program': 'src/cli/program.ts',
|
|
8
|
+
},
|
|
9
|
+
format: ['esm'],
|
|
10
|
+
dts: true,
|
|
11
|
+
sourcemap: true,
|
|
12
|
+
clean: true,
|
|
13
|
+
splitting: false,
|
|
14
|
+
target: 'node22',
|
|
15
|
+
})
|