@vpxa/aikit 0.1.99 → 0.1.100

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.
Files changed (36) hide show
  1. package/README.md +29 -33
  2. package/package.json +1 -2
  3. package/packages/aikit-client/dist/index.d.ts +27 -27
  4. package/packages/aikit-client/dist/index.js +2 -2
  5. package/packages/analyzers/dist/index.js +2 -2
  6. package/packages/cli/dist/index.js +2 -2
  7. package/packages/cli/dist/init-DlY4IHCF.js +7 -0
  8. package/packages/cli/dist/{templates-DVcEiTlc.js → templates-Dz2d2veK.js} +9 -9
  9. package/packages/cli/dist/{user-Dj8KE0_0.js → user-DfEC00FY.js} +1 -1
  10. package/packages/core/dist/index.d.ts +8 -8
  11. package/packages/core/dist/index.js +1 -1
  12. package/packages/dashboard/dist/assets/{index-C6D-PCp0.js → index-CxrC6OtB.js} +3 -3
  13. package/packages/dashboard/dist/index.html +1 -1
  14. package/packages/enterprise-bridge/dist/index.d.ts +1 -1
  15. package/packages/enterprise-bridge/dist/index.js +1 -1
  16. package/packages/indexer/dist/index.d.ts +6 -6
  17. package/packages/server/dist/index.d.ts +1 -1
  18. package/packages/server/dist/index.js +1 -1
  19. package/packages/server/dist/server-DfCR_Bix.js +1282 -0
  20. package/packages/server/dist/{version-check-AMfxaZUw.js → version-check-Bj07vc5x.js} +1 -1
  21. package/packages/store/dist/index.d.ts +9 -22
  22. package/packages/store/dist/index.js +6 -6
  23. package/packages/tools/dist/index.d.ts +16 -15
  24. package/packages/tools/dist/index.js +6 -6
  25. package/scaffold/dist/adapters/intellij.mjs +3 -0
  26. package/scaffold/dist/adapters/zed.mjs +4 -0
  27. package/scaffold/dist/definitions/agents.mjs +1 -1
  28. package/scaffold/dist/definitions/bodies.mjs +16 -16
  29. package/scaffold/dist/definitions/flows.mjs +32 -32
  30. package/scaffold/dist/definitions/hooks.mjs +1 -1
  31. package/scaffold/dist/definitions/prompts.mjs +7 -7
  32. package/scaffold/dist/definitions/protocols.mjs +28 -24
  33. package/scaffold/dist/definitions/skills.mjs +67 -67
  34. package/scaffold/dist/definitions/tools.mjs +1 -1
  35. package/packages/cli/dist/init-CVtbu7zj.js +0 -7
  36. package/packages/server/dist/server-DZ1V42_x.js +0 -1282
package/README.md CHANGED
@@ -167,12 +167,7 @@ Tools supporting `workspaces` param: `search`, `find`, `symbol`.
167
167
  ### Code Analysis
168
168
  | Tool | CLI | Description |
169
169
  |------|-----|-------------|
170
- | `aikit_analyze_structure` | `aikit analyze structure` | Project structure analysis |
171
- | `aikit_analyze_dependencies` | `aikit analyze deps` | Dependency graph |
172
- | `aikit_analyze_symbols` | `aikit analyze symbols` | Symbol extraction |
173
- | `aikit_analyze_patterns` | `aikit analyze patterns` | Code pattern detection |
174
- | `aikit_analyze_entry_points` | `aikit analyze entry-points` | Entry point discovery: handlers, CDK constructs, test suites, package exports (walks monorepo workspaces) |
175
- | `aikit_analyze_diagram` | `aikit analyze diagram` | Mermaid diagram generation |
170
+ | `aikit_analyze` | `aikit analyze <aspect>` | Unified analysis entry point for `structure`, `dependencies`, `symbols`, `patterns`, `entry_points`, and `diagram` |
176
171
  | `aikit_blast_radius` | `aikit analyze blast-radius` | Change impact analysis |
177
172
 
178
173
  ### Context Management
@@ -214,11 +209,7 @@ Tools supporting `workspaces` param: `search`, `find`, `symbol`.
214
209
  ### Knowledge Management
215
210
  | Tool | CLI | Description |
216
211
  |------|-----|-------------|
217
- | `aikit_remember` | `aikit remember` | Store curated knowledge |
218
- | `aikit_update` | `aikit update` | Update existing entries |
219
- | `aikit_forget` | `aikit forget` | Remove entries |
220
- | `aikit_read` | `aikit read` | Read entry content |
221
- | `aikit_list` | `aikit list` | List entries |
212
+ | `aikit_knowledge` | `aikit knowledge <action>` | Unified knowledge entry point for `remember`, `read`, `update`, `forget`, and `list` |
222
213
  | `aikit_produce_knowledge` | — | Auto-generate knowledge from analysis |
223
214
 
224
215
  ### Git & Environment
@@ -525,7 +516,7 @@ pnpm lint # Lint (Biome)
525
516
 
526
517
  ### Search & Retrieval
527
518
 
528
- #### `aikit_search` — Hybrid search across the knowledge base
519
+ #### `aikit_search` — Hybrid search across the AI Kit index
529
520
 
530
521
  Find relevant code, docs, patterns, and curated knowledge using hybrid (vector + keyword), semantic, or keyword-only search.
531
522
 
@@ -571,7 +562,9 @@ No parameters. Returns total records, total files, content type breakdown, last
571
562
 
572
563
  These tools give the agent **persistent, version-tracked memory** that survives across sessions. Knowledge is stored as markdown files with YAML frontmatter in the `curated/` directory and simultaneously indexed into the vector store for semantic search.
573
564
 
574
- #### `aikit_remember` — Store new knowledge
565
+ #### `aikit_knowledge` — Unified curated knowledge tool
566
+
567
+ Use the `action` parameter to choose the operation: `remember`, `read`, `update`, `forget`, or `list`.
575
568
 
576
569
  | Parameter | Type | Required | Description |
577
570
  |-----------|------|----------|-------------|
@@ -582,7 +575,7 @@ These tools give the agent **persistent, version-tracked memory** that survives
582
575
 
583
576
  **What to remember**: Architecture decisions, coding conventions, recurring patterns, API contracts, deployment procedures, debugging solutions, team agreements, review findings.
584
577
 
585
- #### `aikit_update` — Update existing knowledge
578
+ #### `aikit_knowledge` with `action: "update"` — Update existing knowledge
586
579
 
587
580
  | Parameter | Type | Required | Description |
588
581
  |-----------|------|----------|-------------|
@@ -592,7 +585,7 @@ These tools give the agent **persistent, version-tracked memory** that survives
592
585
 
593
586
  Increments version number and appends to the entry's changelog.
594
587
 
595
- #### `aikit_read` — Read a curated entry
588
+ #### `aikit_knowledge` with `action: "read"` — Read a curated entry
596
589
 
597
590
  | Parameter | Type | Required | Description |
598
591
  |-----------|------|----------|-------------|
@@ -600,7 +593,7 @@ Increments version number and appends to the entry's changelog.
600
593
 
601
594
  **Returns**: Full metadata (title, version, tags, created, updated) and content.
602
595
 
603
- #### `aikit_list` — List curated entries
596
+ #### `aikit_knowledge` with `action: "list"` — List curated entries
604
597
 
605
598
  | Parameter | Type | Required | Description |
606
599
  |-----------|------|----------|-------------|
@@ -609,7 +602,7 @@ Increments version number and appends to the entry's changelog.
609
602
 
610
603
  **Returns**: All entries with title, version, tags, path, and 80-char content preview.
611
604
 
612
- #### `aikit_forget` — Remove a curated entry
605
+ #### `aikit_knowledge` with `action: "forget"` — Remove a curated entry
613
606
 
614
607
  | Parameter | Type | Required | Description |
615
608
  |-----------|------|----------|-------------|
@@ -637,9 +630,9 @@ Incremental mode (default) only re-indexes files whose content hash has changed.
637
630
  | `scope` | string | no | `.` (root) | Root path to analyze |
638
631
  | `aspects` | enum[] | no | `["all"]` | `all`, `structure`, `dependencies`, `symbols`, `patterns`, `entry-points`, `diagrams` |
639
632
 
640
- Runs deterministic analyzers, then returns structured instructions for the agent to synthesize and store findings using `aikit_remember`.
633
+ Runs deterministic analyzers, then returns structured instructions for the agent to synthesize and store findings using `aikit_knowledge` with `action: "remember"`.
641
634
 
642
- #### `aikit_analyze_structure` — File/directory tree with language stats
635
+ #### `aikit_analyze` with `aspect: "structure"` — File/directory tree with language stats
643
636
 
644
637
  | Parameter | Type | Required | Default | Description |
645
638
  |-----------|------|----------|---------|-------------|
@@ -647,7 +640,7 @@ Runs deterministic analyzers, then returns structured instructions for the agent
647
640
  | `max_depth` | number (1–10) | no | 6 | Maximum directory depth |
648
641
  | `format` | enum | no | `markdown` | `json` or `markdown` |
649
642
 
650
- #### `aikit_analyze_dependencies` — Import/require dependency graph (with confidence)
643
+ #### `aikit_analyze` with `aspect: "dependencies"` — Import/require dependency graph (with confidence)
651
644
 
652
645
  | Parameter | Type | Required | Default | Description |
653
646
  |-----------|------|----------|---------|-------------|
@@ -656,7 +649,7 @@ Runs deterministic analyzers, then returns structured instructions for the agent
656
649
 
657
650
  Dependency results include a **confidence** level per import: `high` (ES static imports), `medium` (dynamic imports, require()), `low` (inferred). The markdown format shows a Confidence column in dependency tables.
658
651
 
659
- #### `aikit_analyze_symbols` — Exported & local symbols
652
+ #### `aikit_analyze` with `aspect: "symbols"` — Exported & local symbols
660
653
 
661
654
  | Parameter | Type | Required | Default | Description |
662
655
  |-----------|------|----------|---------|-------------|
@@ -664,13 +657,13 @@ Dependency results include a **confidence** level per import: `high` (ES static
664
657
  | `filter` | string | no | — | Filter symbols by name substring |
665
658
  | `format` | enum | no | `markdown` | `json` or `markdown` |
666
659
 
667
- #### `aikit_analyze_patterns` — Detect architectural patterns & frameworks
660
+ #### `aikit_analyze` with `aspect: "patterns"` — Detect architectural patterns & frameworks
668
661
 
669
662
  | Parameter | Type | Required | Description |
670
663
  |-----------|------|----------|-------------|
671
664
  | `path` | string | **yes** | Root path |
672
665
 
673
- #### `aikit_analyze_entry_points` — Find Lambda handlers, CDK constructs, test suites, package exports
666
+ #### `aikit_analyze` with `aspect: "entry_points"` — Find Lambda handlers, CDK constructs, test suites, package exports
674
667
 
675
668
  Walks monorepo workspace packages (pnpm-workspace.yaml / package.json#workspaces), parses `exports` fields, detects CDK constructs and test suites.
676
669
 
@@ -678,7 +671,7 @@ Walks monorepo workspace packages (pnpm-workspace.yaml / package.json#workspaces
678
671
  |-----------|------|----------|-------------|
679
672
  | `path` | string | **yes** | Root path |
680
673
 
681
- #### `aikit_analyze_diagram` — Generate Mermaid architecture/dependency diagrams
674
+ #### `aikit_analyze` with `aspect: "diagram"` — Generate Mermaid architecture/dependency diagrams
682
675
 
683
676
  | Parameter | Type | Required | Default | Description |
684
677
  |-----------|------|----------|---------|-------------|
@@ -1250,9 +1243,9 @@ When writing instructions for an AI agent (e.g., in `.copilot-instructions.md`,
1250
1243
  ### Recommended Agent Instruction Template
1251
1244
 
1252
1245
  ```markdown
1253
- ## Knowledge Base Usage
1246
+ ## AI Kit Knowledge Usage
1254
1247
 
1255
- You have access to a persistent knowledge base via MCP tools. Use it proactively.
1248
+ You have access to persistent AI Kit knowledge via MCP tools. Use it proactively.
1256
1249
 
1257
1250
  ### Before Starting Any Task
1258
1251
  1. **Search first**: Use `aikit_search` with a natural language query describing your task to find relevant context, prior decisions, conventions, and patterns before writing code.
@@ -1269,12 +1262,13 @@ You have access to a persistent knowledge base via MCP tools. Use it proactively
1269
1262
  - **View a full file**: `aikit_lookup({ path: "src/services/dispatcher.ts" })`
1270
1263
 
1271
1264
  ### Follow the Hints
1272
- Every tool response includes a `_Next:` suggestion at the bottom. Follow these hints for efficient workflows — they guide you to logical next actions (e.g., after `aikit_search`, the hint suggests `aikit_lookup` or `aikit_analyze_structure`).
1265
+ Every tool response includes a `_Next:` suggestion at the bottom. Follow these hints for efficient workflows — they guide you to logical next actions (e.g., after `aikit_search`, the hint suggests `aikit_lookup` or `aikit_analyze`).
1273
1266
 
1274
1267
  ### After Completing a Task
1275
1268
  1. **Remember decisions**: If you made an architecture or design decision, store it:
1276
1269
  ```
1277
- aikit_remember({
1270
+ aikit_knowledge({
1271
+ action: "remember",
1278
1272
  title: "Use event-driven pattern for notification fanout",
1279
1273
  content: "## Decision\n\n...\n\n## Rationale\n\n...\n\n## Alternatives Considered\n\n...",
1280
1274
  category: "decisions",
@@ -1283,7 +1277,8 @@ Every tool response includes a `_Next:` suggestion at the bottom. Follow these h
1283
1277
  ```
1284
1278
  2. **Remember patterns**: If you established a reusable code pattern:
1285
1279
  ```
1286
- aikit_remember({
1280
+ aikit_knowledge({
1281
+ action: "remember",
1287
1282
  title: "CDK construct pattern for SQS-Lambda integration",
1288
1283
  content: "## Pattern\n\n```typescript\n...\n```\n\n## When to Use\n\n...",
1289
1284
  category: "patterns",
@@ -1292,7 +1287,8 @@ Every tool response includes a `_Next:` suggestion at the bottom. Follow these h
1292
1287
  ```
1293
1288
  3. **Remember troubleshooting**: If you solved a tricky bug:
1294
1289
  ```
1295
- aikit_remember({
1290
+ aikit_knowledge({
1291
+ action: "remember",
1296
1292
  title: "LanceDB dimension mismatch after model change",
1297
1293
  content: "## Problem\n\n...\n\n## Solution\n\nRun `aikit_reindex({ full: true })`...",
1298
1294
  category: "troubleshooting",
@@ -1316,9 +1312,9 @@ Every tool response includes a `_Next:` suggestion at the bottom. Follow these h
1316
1312
 
1317
1313
  ### Codebase Analysis (for onboarding or deep understanding)
1318
1314
  - Run `aikit_produce_knowledge({ aspects: ["all"] })` to get analysis baselines and follow the synthesis instructions to populate the KB
1319
- - Use `aikit_analyze_structure({ path: "." })` for project layout overview
1320
- - Use `aikit_analyze_dependencies({ path: ".", format: "mermaid" })` for dependency visualization
1321
- - Use `aikit_analyze_patterns({ path: "." })` to detect frameworks and conventions
1315
+ - Use `aikit_analyze({ aspect: "structure", path: "." })` for project layout overview
1316
+ - Use `aikit_analyze({ aspect: "dependencies", path: ".", format: "mermaid" })` for dependency visualization
1317
+ - Use `aikit_analyze({ aspect: "patterns", path: "." })` to detect frameworks and conventions
1322
1318
 
1323
1319
  ### Index Maintenance
1324
1320
  - Run `aikit_reindex()` after significant code changes (incremental, fast)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.99",
3
+ "version": "0.1.100",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -54,7 +54,6 @@
54
54
  "@mcp-ui/server": "^6.x",
55
55
  "@modelcontextprotocol/ext-apps": "^1.x",
56
56
  "@modelcontextprotocol/sdk": "^1.x",
57
- "better-sqlite3": "^12.x",
58
57
  "diff": "^9.x",
59
58
  "express": "^5.x",
60
59
  "gpt-tokenizer": "^3.x",
@@ -4,19 +4,19 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
4
 
5
5
  //#region packages/aikit-client/src/types.d.ts
6
6
  /**
7
- * IKBClient — Unified data access interface for AI Kit consumers.
7
+ * IAikitClient — Unified data access interface for AI Kit consumers.
8
8
  *
9
9
  * Implemented by:
10
- * - DirectKBClient (in-process, used by TUI)
11
- * - McpKBClient (over MCP transport, used by Dashboard)
10
+ * - DirectAikitClient (in-process, used by TUI)
11
+ * - McpAikitClient (over MCP transport, used by Dashboard)
12
12
  */
13
- interface KBStatus {
13
+ interface AikitStatus {
14
14
  totalRecords: number;
15
15
  totalFiles: number;
16
16
  lastIndexedAt: string | null;
17
17
  onboarded: boolean;
18
18
  }
19
- interface KBSearchResult {
19
+ interface AikitSearchResult {
20
20
  sourcePath: string;
21
21
  contentType: string;
22
22
  score: number;
@@ -25,14 +25,14 @@ interface KBSearchResult {
25
25
  startLine?: number;
26
26
  endLine?: number;
27
27
  }
28
- interface KBKnowledgeEntry {
28
+ interface AikitKnowledgeEntry {
29
29
  path: string;
30
30
  title: string;
31
31
  category: string;
32
32
  tags: string[];
33
33
  content: string;
34
34
  }
35
- interface KBGraphData {
35
+ interface AikitGraphData {
36
36
  nodes: Array<{
37
37
  id: string;
38
38
  name: string;
@@ -45,20 +45,20 @@ interface KBGraphData {
45
45
  type: string;
46
46
  }>;
47
47
  }
48
- interface IKBClient {
48
+ interface IAikitClient {
49
49
  /** Get AI Kit status. */
50
- getStatus(): Promise<KBStatus>;
50
+ getStatus(): Promise<AikitStatus>;
51
51
  /** Search AI Kit. */
52
52
  search(query: string, options?: {
53
53
  limit?: number;
54
54
  mode?: 'hybrid' | 'semantic' | 'keyword';
55
- }): Promise<KBSearchResult[]>;
55
+ }): Promise<AikitSearchResult[]>;
56
56
  /** List curated knowledge entries. */
57
- listKnowledge(): Promise<KBKnowledgeEntry[]>;
57
+ listKnowledge(): Promise<AikitKnowledgeEntry[]>;
58
58
  /** Read a specific curated entry. */
59
- readKnowledge(path: string): Promise<KBKnowledgeEntry | null>;
59
+ readKnowledge(path: string): Promise<AikitKnowledgeEntry | null>;
60
60
  /** Get knowledge graph data. */
61
- getGraph(query?: string): Promise<KBGraphData>;
61
+ getGraph(query?: string): Promise<AikitGraphData>;
62
62
  /** Get file tree of indexed sources. */
63
63
  getFileTree(): Promise<string[]>;
64
64
  }
@@ -80,40 +80,40 @@ interface DirectClientDeps {
80
80
  /** Function to read a single curated entry */
81
81
  readCurated?: (path: string) => Promise<CuratedEntry | null>;
82
82
  }
83
- declare class DirectKBClient implements IKBClient {
83
+ declare class DirectAikitClient implements IAikitClient {
84
84
  private readonly deps;
85
85
  constructor(deps: DirectClientDeps);
86
- getStatus(): Promise<KBStatus>;
86
+ getStatus(): Promise<AikitStatus>;
87
87
  search(query: string, options?: {
88
88
  limit?: number;
89
89
  mode?: 'hybrid' | 'semantic' | 'keyword';
90
- }): Promise<KBSearchResult[]>;
91
- listKnowledge(): Promise<KBKnowledgeEntry[]>;
92
- readKnowledge(path: string): Promise<KBKnowledgeEntry | null>;
93
- getGraph(query?: string): Promise<KBGraphData>;
90
+ }): Promise<AikitSearchResult[]>;
91
+ listKnowledge(): Promise<AikitKnowledgeEntry[]>;
92
+ readKnowledge(path: string): Promise<AikitKnowledgeEntry | null>;
93
+ getGraph(query?: string): Promise<AikitGraphData>;
94
94
  getFileTree(): Promise<string[]>;
95
95
  private getEdgesForNodes;
96
96
  }
97
97
  //#endregion
98
98
  //#region packages/aikit-client/src/mcp-client.d.ts
99
- declare class McpKBClient implements IKBClient {
99
+ declare class McpAikitClient implements IAikitClient {
100
100
  private readonly client;
101
101
  constructor(client: Client);
102
- getStatus(): Promise<KBStatus>;
102
+ getStatus(): Promise<AikitStatus>;
103
103
  search(query: string, options?: {
104
104
  limit?: number;
105
105
  mode?: 'hybrid' | 'semantic' | 'keyword';
106
- }): Promise<KBSearchResult[]>;
107
- listKnowledge(): Promise<KBKnowledgeEntry[]>;
108
- readKnowledge(path: string): Promise<KBKnowledgeEntry | null>;
109
- getGraph(query?: string): Promise<KBGraphData>;
106
+ }): Promise<AikitSearchResult[]>;
107
+ listKnowledge(): Promise<AikitKnowledgeEntry[]>;
108
+ readKnowledge(path: string): Promise<AikitKnowledgeEntry | null>;
109
+ getGraph(query?: string): Promise<AikitGraphData>;
110
110
  getFileTree(): Promise<string[]>;
111
111
  }
112
112
  //#endregion
113
113
  //#region packages/aikit-client/src/parsers.d.ts
114
114
  /**
115
115
  * Content parsers for MCP tool responses.
116
- * Used by McpKBClient to parse structuredContent from tool calls.
116
+ * Used by McpAikitClient to parse structuredContent from tool calls.
117
117
  */
118
118
  interface ParsedContent<T = unknown> {
119
119
  text: string;
@@ -144,4 +144,4 @@ declare function parseToolResult<T = unknown>(result: {
144
144
  */
145
145
  declare function tryParseJson<T = unknown>(text: string): T | undefined;
146
146
  //#endregion
147
- export { type DirectClientDeps, DirectKBClient, type IKBClient, type KBGraphData, type KBKnowledgeEntry, type KBSearchResult, type KBStatus, McpKBClient, type ParsedContent, extractStructured, extractText, parseToolResult, tryParseJson };
147
+ export { type AikitGraphData, type AikitKnowledgeEntry, type AikitSearchResult, type AikitStatus, DirectAikitClient, type DirectClientDeps, type IAikitClient, McpAikitClient, type ParsedContent, extractStructured, extractText, parseToolResult, tryParseJson };
@@ -1,5 +1,5 @@
1
1
  const e=1e3;var t=class{constructor(e){this.deps=e}async getStatus(){let e=await this.deps.store.getStats();return{totalRecords:e.totalRecords,totalFiles:e.totalFiles,lastIndexedAt:e.lastIndexedAt??null,onboarded:e.totalRecords>0}}async search(e,t){let n=t?.limit??10,i=t?.mode??`hybrid`;if(i===`keyword`)return(await this.deps.store.ftsSearch(e,{limit:n})).map(r);let a=await this.deps.embedder.embedQuery(e);if(i===`semantic`)return(await this.deps.store.search(a,{limit:n})).map(r);let[o,s]=await Promise.all([this.deps.store.search(a,{limit:n*2}),this.deps.store.ftsSearch(e,{limit:n*2}).catch(()=>[])]),c=new Map;for(let e of[...o,...s]){let t=c.get(e.record.id);(!t||e.score>t.score)&&c.set(e.record.id,e)}return[...c.values()].sort((e,t)=>t.score-e.score).slice(0,n).map(r)}async listKnowledge(){return this.deps.listCurated?(await this.deps.listCurated()).map(n):[]}async readKnowledge(e){if(!this.deps.readCurated)return null;let t=await this.deps.readCurated(e);return t?n(t):null}async getGraph(t){if(!this.deps.graphStore)return{nodes:[],edges:[]};let n=await this.deps.graphStore.findNodes(t?{namePattern:t,limit:500}:{limit:500});if(n.length===0)return{nodes:[],edges:[]};let r=t?await this.getEdgesForNodes(n):await this.deps.graphStore.findEdges({limit:e});return{nodes:n.map(e=>({id:e.id,name:e.name,type:e.type,...e.sourcePath?{sourcePath:e.sourcePath}:{}})),edges:i(r).map(e=>({fromId:e.fromId,toId:e.toId,type:e.type}))}}async getFileTree(){return this.deps.store.listSourcePaths()}async getEdgesForNodes(t){let n=this.deps.graphStore;if(!n)return[];let r=t.flatMap(t=>[n.findEdges({fromId:t.id,limit:e}),n.findEdges({toId:t.id,limit:e})]);return(await Promise.all(r)).flat()}};function n(e){return{path:e.path,title:e.title,category:e.category,tags:e.tags,content:e.content}}function r(e){return{sourcePath:e.record.sourcePath,contentType:e.record.contentType,score:e.score,content:e.record.content,headingPath:e.record.headingPath,startLine:e.record.startLine,endLine:e.record.endLine}}function i(e){let t=new Map;for(let n of e)t.set(n.id,n);return[...t.values()]}function a(e){return!Array.isArray(e?.content)||e.content.length===0?``:e.content.filter(e=>typeof e==`object`&&!!e).filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
2
- `)}function o(e){return e?.structuredContent}function s(e){return{text:a(e),structured:o(e)}}function c(e){try{return JSON.parse(e)}catch{return}}var l=class{constructor(e){this.client=e}async getStatus(){let e=await this.client.callTool({name:`status`,arguments:{}}),t=d(e);if(t)return{totalRecords:g(t.totalRecords),totalFiles:g(t.totalFiles),lastIndexedAt:v(t.lastIndexedAt),onboarded:!!t.onboarded};let n=u(e);return{totalRecords:f(n,/Records:\s*(\d+)/i),totalFiles:f(n,/Files:\s*(\d+)/i),lastIndexedAt:null,onboarded:!/not onboarded/i.test(n)}}async search(e,t){let n=await this.client.callTool({name:`search`,arguments:{query:e,limit:t?.limit??10,search_mode:t?.mode??`hybrid`}}),r=d(n);return r?.results?r.results.map(e=>({sourcePath:y(e.sourcePath??e.path),contentType:y(e.contentType,`unknown`),score:g(e.score),content:y(e.content??e.snippet),headingPath:b(e.headingPath),startLine:_(e.startLine),endLine:_(e.endLine)})):p(u(n))}async listKnowledge(){let e=d(await this.client.callTool({name:`list`,arguments:{}}));return e?.entries?e.entries.map(e=>({path:y(e.path),title:y(e.title),category:y(e.category),tags:x(e.tags),content:y(e.content)})):[]}async readKnowledge(e){try{let t=u(await this.client.callTool({name:`read`,arguments:{path:e}}));return!t||/not found/i.test(t)?null:{path:e,title:e.split(`/`).pop()??e,category:e.split(`/`).at(-2)??`uncategorized`,tags:[],content:t}}catch{return null}}async getGraph(e){let t=m(u(await this.client.callTool({name:`graph`,arguments:{action:`find_nodes`,...e?{name_pattern:e}:{},limit:500}})));return t.length===0?{nodes:[],edges:[]}:{nodes:t,edges:h(u(await this.client.callTool({name:`graph`,arguments:{action:`find_edges`,limit:1e3}})))}}async getFileTree(){let e=await this.client.callTool({name:`find`,arguments:{glob:`**/*`,limit:1e4}}),t=d(e);return t?.results?t.results.map(e=>typeof e==`string`?e:e.path??``).filter(e=>e.length>0):u(e).split(`
2
+ `)}function o(e){return e?.structuredContent}function s(e){return{text:a(e),structured:o(e)}}function c(e){try{return JSON.parse(e)}catch{return}}var l=class{constructor(e){this.client=e}async getStatus(){let e=await this.client.callTool({name:`status`,arguments:{}}),t=d(e);if(t)return{totalRecords:g(t.totalRecords),totalFiles:g(t.totalFiles),lastIndexedAt:v(t.lastIndexedAt),onboarded:!!t.onboarded};let n=u(e);return{totalRecords:f(n,/Records:\s*(\d+)/i),totalFiles:f(n,/Files:\s*(\d+)/i),lastIndexedAt:null,onboarded:!/not onboarded/i.test(n)}}async search(e,t){let n=await this.client.callTool({name:`search`,arguments:{query:e,limit:t?.limit??10,search_mode:t?.mode??`hybrid`}}),r=d(n);return r?.results?r.results.map(e=>({sourcePath:y(e.sourcePath??e.path),contentType:y(e.contentType,`unknown`),score:g(e.score),content:y(e.content??e.snippet),headingPath:b(e.headingPath),startLine:_(e.startLine),endLine:_(e.endLine)})):p(u(n))}async listKnowledge(){let e=d(await this.client.callTool({name:`knowledge`,arguments:{action:`list`}}));return e?.entries?e.entries.map(e=>({path:y(e.path),title:y(e.title),category:y(e.category),tags:x(e.tags),content:y(e.content)})):[]}async readKnowledge(e){try{let t=u(await this.client.callTool({name:`knowledge`,arguments:{action:`read`,path:e}}));return!t||/not found/i.test(t)?null:{path:e,title:e.split(`/`).pop()??e,category:e.split(`/`).at(-2)??`uncategorized`,tags:[],content:t}}catch{return null}}async getGraph(e){let t=m(u(await this.client.callTool({name:`graph`,arguments:{action:`find_nodes`,...e?{name_pattern:e}:{},limit:500}})));return t.length===0?{nodes:[],edges:[]}:{nodes:t,edges:h(u(await this.client.callTool({name:`graph`,arguments:{action:`find_edges`,limit:1e3}})))}}async getFileTree(){let e=await this.client.callTool({name:`find`,arguments:{glob:`**/*`,limit:1e4}}),t=d(e);return t?.results?t.results.map(e=>typeof e==`string`?e:e.path??``).filter(e=>e.length>0):u(e).split(`
3
3
  `).map(e=>e.trim()).filter(e=>e.length>0)}};function u(e){return a(e)}function d(e){return o(e)}function f(e,t){let n=t.exec(e);return n?Number.parseInt(n[1],10):0}function p(e){let t=[],n=e.split(/\n(?=\d+\.\s|\*\*)/);for(let e of n){let n=/(?:\*\*|`)([^*`]+?)(?:\*\*|`)/.exec(e),r=/score:\s*([\d.]+)/i.exec(e);n&&t.push({sourcePath:n[1].trim(),contentType:`unknown`,score:r?Number.parseFloat(r[1]):0,content:e.replace(/^.*\n/,``).trim().slice(0,200)})}return t}function m(e){let t=[];for(let n of e.split(`
4
4
  `)){let e=/\*\*(.+?)\*\*\s*\(([^,)]+)(?:,\s*id:\s*`?([\w-]+)`?)?/.exec(n);e&&t.push({id:e[3]??`node-${t.length}`,name:e[1],type:e[2]})}return t}function h(e){let t=[];for(let n of e.split(`
5
- `)){let e=/`?([\w-]+)`?\s*[—-]+\[(\w+)\][→>]\s*`?([\w-]+)`?/.exec(n);e&&t.push({fromId:e[1],toId:e[3],type:e[2]})}return t}function g(e){return typeof e==`number`?e:0}function _(e){return typeof e==`number`?e:void 0}function v(e){return typeof e==`string`?e:null}function y(e,t=``){return typeof e==`string`?e:t}function b(e){return typeof e==`string`?e:void 0}function x(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}export{t as DirectKBClient,l as McpKBClient,o as extractStructured,a as extractText,s as parseToolResult,c as tryParseJson};
5
+ `)){let e=/`?([\w-]+)`?\s*[—-]+\[(\w+)\][→>]\s*`?([\w-]+)`?/.exec(n);e&&t.push({fromId:e[1],toId:e[3],type:e[2]})}return t}function g(e){return typeof e==`number`?e:0}function _(e){return typeof e==`number`?e:void 0}function v(e){return typeof e==`string`?e:null}function y(e,t=``){return typeof e==`string`?e:t}function b(e){return typeof e==`string`?e:void 0}function x(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}export{t as DirectAikitClient,l as McpAikitClient,o as extractStructured,a as extractText,s as parseToolResult,c as tryParseJson};
@@ -28,7 +28,7 @@ import{access as e,readFile as t,readdir as n,stat as r}from"node:fs/promises";i
28
28
  `);for(let t of e.diagrams)n.push(t.output);n.push(``)}let r=this.buildCrossReferences(e);if(r.length>0){n.push(`#### Cross-References
29
29
  `),n.push(`_Connections between baselines to aid synthesis:_
30
30
  `);for(let e of r)n.push(`- ${e}`);n.push(``)}return n.push(`### Your Task: Synthesize Knowledge
31
- `),n.push(`Based on the baselines above and your reading of the source files, produce`),n.push("the following knowledge documents using `aikit_remember`:\n"),n.push(`1. **Domain Overview** (category: \`architecture\`)
31
+ `),n.push(`Based on the baselines above and your reading of the source files, produce`),n.push('the following knowledge documents using `aikit_knowledge({ action: "remember", ... })`:\n'),n.push(`1. **Domain Overview** (category: \`architecture\`)
32
32
  - What this service does, boundary with other services
33
33
  - Key entities and their lifecycle
34
34
  `),n.push(`2. **Architecture Summary** (category: \`architecture\`)
@@ -41,7 +41,7 @@ import{access as e,readFile as t,readdir as n,stat as r}from"node:fs/promises";i
41
41
  - Naming conventions observed
42
42
  - File organization rules
43
43
  - Testing patterns
44
- `),n.push("Store each as a separate `aikit_remember` call with descriptive titles.\n"),n.join(`
44
+ `),n.push('Store each as a separate `aikit_knowledge` call with `action: "remember"` and a descriptive title.\n'),n.join(`
45
45
  `)}buildCrossReferences(e){let t=[],n=new Set;if(e.symbols?.output)for(let t of e.symbols.output.matchAll(/`(\w+)`\s*\((?:function|class|interface|type|const|enum)\)/g))n.add(t[1]);let r=new Set;if(e.entryPoints?.output)for(let t of e.entryPoints.output.matchAll(/`(\w+)`.*?(?:handler|main|server|cli|test|construct)/gi))r.add(t[1]);for(let e of r)n.has(e)&&t.push(`Entry point \`${e}\` is also listed in symbols — check its call graph for downstream dependencies`);if(e.patterns?.output&&n.size>0){for(let r of[`Singleton`,`Factory`,`Observer`,`Builder`,`Strategy`,`Middleware`,`Repository`])if(e.patterns.output.includes(r)){let i=e.patterns.output.split(r)[1]?.slice(0,200)??``;for(let e of n)if(i.includes(e)){t.push(`Symbol \`${e}\` uses the ${r} pattern`);break}}}return t}};const M=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),N=[{dirs:[`adapters`,`ports`],pattern:`Hexagonal Architecture`,description:`Ports & adapters (hexagonal) separation`},{dirs:[`domain`,`infrastructure`,`application`],pattern:`Clean Architecture`,description:`Layered with domain/infrastructure separation`},{dirs:[`controllers`,`models`],pattern:`MVC Pattern`,description:`Model-View-Controller structure`},{dirs:[`repositories`],pattern:`Repository Pattern`,description:`Data access abstraction via repositories`},{dirs:[`factories`],pattern:`Factory Pattern`,description:`Object creation via factories`},{dirs:[`handlers`],pattern:`Handler Pattern`,description:`Event/request handler separation`},{dirs:[`middleware`],pattern:`Middleware Pattern`,description:`Request pipeline middleware`},{dirs:[`hooks`],pattern:`React Hooks`,description:`Custom React hooks for logic reuse`},{dirs:[`components`],pattern:`Component Architecture`,description:`UI component-based structure`},{dirs:[`stacks`,`constructs`],pattern:`CDK IaC`,description:`AWS CDK infrastructure as code`},{dirs:[`lambdas`,`functions`],pattern:`Serverless`,description:`Serverless function architecture`}];function P(e){if(e.length<=3)return e;let t=new Map;for(let n of e){let e=n.split(`/`),r=e.length>1?e.slice(0,-1).join(`/`):`.`,i=t.get(r);i?i.push(n):t.set(r,[n])}let n=[];for(let[e,r]of t)r.length>=3?n.push(`${e}/ (${r.length} files)`):n.push(...r);return n.slice(0,5)}const F=[{regex:/container\.register|@injectable|@inject/i,pattern:`Dependency Injection`,description:`IoC container or DI decorators`},{regex:/\.pipe\(|Observable|BehaviorSubject/i,pattern:`Reactive (RxJS)`,description:`Reactive programming with observables`,lang:`js`},{regex:/createContext|useContext/i,pattern:`React Context`,description:`React Context API for state sharing`,lang:`js`},{regex:/createSlice|configureStore/i,pattern:`Redux Toolkit`,description:`Redux state management`,lang:`js`},{regex:/defineStore|usePinia/i,pattern:`Pinia Store`,description:`Vue Pinia state management`,lang:`js`},{regex:/\.(test|spec)\.[jt]sx?|describe\s*\(|\bit\s*\([\s'"]/i,pattern:`Test Suite`,description:`Unit/integration test files`},{regex:/@SpringBootApplication|@EnableAutoConfiguration/,pattern:`Spring Boot`,description:`Spring Boot application framework`,lang:`java`,definitive:!0},{regex:/@Autowired|@Component|@Service|@Repository|@Controller/,pattern:`Spring DI`,description:`Spring dependency injection`,lang:`java`},{regex:/@RestController|@RequestMapping|@GetMapping|@PostMapping/,pattern:`Spring REST`,description:`Spring REST API controllers`,lang:`java`},{regex:/app\s*=\s*Flask\s*\(|@app\.route/,pattern:`Flask`,description:`Flask web framework`,lang:`python`},{regex:/app\s*=\s*FastAPI\s*\(|@app\.get|@app\.post/,pattern:`FastAPI`,description:`FastAPI web framework`,lang:`python`},{regex:/func\s+main\s*\(\s*\)|http\.ListenAndServe/,pattern:`Go Application`,description:`Go main application`,lang:`go`},{regex:/export\s+(?:async\s+)?function\s+create[A-Z]\w+/,pattern:`Factory`,description:`Object creation via create*() functions`,lang:`js`},{regex:/(?:export\s+)?function\s+wrap[A-Z]\w+/,pattern:`Wrapper/Decorator`,description:`Higher-order function wrapping`,lang:`js`},{regex:/(?:const|let)\s+\w+\s*=\s*new\s+(?:Map|WeakMap)\s*[<(]/,pattern:`Singleton Cache`,description:`Module-level cache with lazy initialization`,lang:`js`},{regex:/Record<string,\s*(?:\w+)?Handler>|\.(?:get|post|put|delete)\s*\(/,pattern:`Router/Dispatcher`,description:`Request routing/dispatch table`,lang:`js`},{regex:/export\s+(?:default\s+)?class\s+\w+\s+extends\s+(?:Construct|Stack|NestedStack|Stage)/,pattern:`CDK Construct`,description:`AWS CDK infrastructure construct`,lang:`js`,definitive:!0}];var I=class{name=`patterns`;async analyze(e,t={}){let n=Date.now(),r=await this.collectDirectories(e),i=this.detectDirectoryPatterns(r,e),a=await this.collectCodeFiles(e),o=await this.detectCodePatterns(a,e),s=[...i,...o],c=await this.detectConfigPatterns(e),l=c.find(e=>e.pattern===`Maven`||e.pattern===`Gradle`||e.pattern===`Gradle (Kotlin DSL)`||e.pattern===`Node.js Project`||e.pattern===`Go Module`||e.pattern===`Rust (Cargo)`),u=new Set([`Ruby (Bundler)`,`PHP (Composer)`,`Swift Package`,`SBT`]);for(let e of c)l&&u.has(e.pattern)||s.push(e);return{output:this.formatMarkdown(s,e),data:{patterns:s,total:s.length},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:a.length,durationMs:Date.now()-n}}}async collectDirectories(e){let t=[],i=async(e,a)=>{if(a>5||!(await r(e).catch(()=>null))?.isDirectory())return;let o=await n(e,{withFileTypes:!0});for(let n of o){if(!n.isDirectory()||M.has(n.name)||n.name.startsWith(`.`))continue;let r=s(e,n.name);t.push(n.name),await i(r,a+1)}};return await i(e,0),t}async collectCodeFiles(e){let t=[],r=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.kt`,`.scala`,`.rb`,`.rs`,`.php`,`.swift`]),i=async e=>{let a=await n(e,{withFileTypes:!0});for(let n of a){if(M.has(n.name)||n.name.startsWith(`.`))continue;let a=s(e,n.name);n.isDirectory()?await i(a):r.has(o(n.name))&&t.push(a)}};return await i(e),t}detectDirectoryPatterns(e,t){let n=new Set(e.map(e=>e.toLowerCase())),r=[];for(let e of N){let t=e.dirs.filter(e=>n.has(e));t.length!==0&&(e.dirs.length>1&&t.length<2||r.push({pattern:e.pattern,description:e.description,locations:t.map(e=>`${e}/`),confidence:t.length===e.dirs.length?`high`:`medium`}))}return r}async detectCodePatterns(e,n){let r=[],i={},a=!1;try{await d.ensure(),a=!0}catch{}let s=e.filter(e=>/Application\.\w+$|Main\.\w+$|app\.\w+$|main\.\w+$/i.test(e)||/Controller|Service|Handler|Router/i.test(e)),l=e.filter(e=>!s.includes(e)),f=[...s.slice(0,50),...l.slice(0,150)];for(let e of f)try{let r=await t(e,`utf-8`),s=o(e).toLowerCase(),l=c(n,e).replace(/\\/g,`/`);if(/analyzers\/src\//.test(l))continue;if(a&&u.has(s)){let e=await p(r,s,l);for(let t of e){i[t.pattern]||(i[t.pattern]=new Set);for(let e of t.locations)i[t.pattern].add(e)}}let d=s===`.java`||s===`.kt`||s===`.scala`?`java`:s===`.py`?`python`:s===`.go`?`go`:`js`;for(let e of F)e.lang&&e.lang!==d||e.regex.test(r)&&(i[e.pattern]||(i[e.pattern]=new Set),i[e.pattern].add(l))}catch{}for(let e of F){let t=i[e.pattern];if(t&&t.size>0){let n=P([...t]);r.push({pattern:e.pattern,description:e.description,locations:n,confidence:e.definitive||t.size>=3?`high`:t.size>=2?`medium`:`low`})}}let m=new Set(F.map(e=>e.pattern));for(let[e,t]of Object.entries(i)){if(m.has(e)||t.size===0)continue;let n=P([...t]);r.push({pattern:e,description:`Detected via AST analysis`,locations:n,confidence:t.size>=3?`high`:t.size>=2?`medium`:`low`})}return r}async detectConfigPatterns(t){let n=[];for(let r of[{file:`Dockerfile`,pattern:`Docker`,description:`Containerized application`},{file:`docker-compose.yml`,pattern:`Docker Compose`,description:`Container orchestration`},{file:`cdk.json`,pattern:`AWS CDK`,description:`AWS CDK infrastructure as code`},{file:`terraform.tf`,pattern:`Terraform`,description:`Terraform IaC`},{file:`main.tf`,pattern:`Terraform`,description:`Terraform IaC`}])try{await e(s(t,r.file)),n.push({pattern:r.pattern,description:r.description,locations:[r.file],confidence:`high`})}catch{}return n}formatMarkdown(e,t){let n=[];n.push(`## Patterns Detected: ${t}\n`),n.push(`**${e.length} patterns** found\n`);let r={high:[],medium:[],low:[]};for(let t of e)r[t.confidence].push(t);for(let[e,t]of Object.entries(r))if(t.length!==0){n.push(`### ${e.charAt(0).toUpperCase()+e.slice(1)} Confidence\n`);for(let e of t)n.push(`- **${e.pattern}**: ${e.description}`),n.push(` Locations: ${e.locations.slice(0,5).join(`, `)}`);n.push(``)}return n.join(`
46
46
  `)}};const L=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`.venv`,`venv`,`__pycache__`,`target`,`vendor`,`bin`,`obj`]),R=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.kt`,`.scala`,`.rs`,`.rb`,`.php`,`.swift`]);async function z(e){let t=Date.now(),n=ve(e);if(n.length===0)return null;let r=n.slice(0,800),i=new Map,a=new Map;for(let t of r){let n=c(e,t).replace(/\\/g,`/`),r=v(t,`utf-8`),s=o(t).toLowerCase(),l=B(r,s);i.set(n,l);let u=me(r,s);a.set(n,u)}let l=ge(r,e),u=ye(e),d=new Map;for(let[t,n]of i){if(G(t))continue;let r=he(v(s(e,t),`utf-8`),o(t));for(let e of n){if(!e.isRelative){let n=be(e.source,u,l);if(!n)continue;let i=n;if(G(i)||t===i)continue;let a;if(a=e.symbols.length>0?e.symbols.filter(e=>RegExp(`\\b${H(e)}\\b`).test(r)):[`*`],a.length===0)continue;let o=`${t}|${i}`,s=d.get(o);if(s)for(let e of a)s.add(e);else d.set(o,new Set(a));continue}let n=_e(t,e.source,l,o(t));if(n.length===0)continue;let i=n[0];if(G(i)||t===i)continue;let a;if(a=e.symbols.length>0?e.symbols.filter(e=>RegExp(`\\b${H(e)}\\b`).test(r)):[`*`],a.length===0)continue;let s=`${t}|${i}`,c=d.get(s);if(c)for(let e of a)c.add(e);else d.set(s,new Set(a))}}let f=[];for(let[e,t]of d){let[n,r]=e.split(`|`);f.push({from:n,to:r,symbols:[...t].sort().slice(0,10)})}return f.sort((e,t)=>t.symbols.length-e.symbols.length),{edges:f,fileCount:r.length,edgeCount:f.length,durationMs:Date.now()-t}}function B(e,t){let n=[];switch(t){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:{let t=/import\s+(?:type\s+)?\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,r;for(;(r=t.exec(e))!==null;){let e=r[1].split(`,`).map(e=>{let t=e.trim().split(/\s+as\s+/);return(t[t.length-1]||``).trim()}).filter(Boolean);n.push({source:r[2],symbols:e,isRelative:r[2].startsWith(`.`)})}let i=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;for(;(r=i.exec(e))!==null;)r[1]!==`type`&&n.push({source:r[2],symbols:[r[1]],isRelative:r[2].startsWith(`.`)});let a=/(?:const|let|var)\s+\{([^}]+)\}\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)/g;for(;(r=a.exec(e))!==null;){let e=r[1].split(`,`).map(e=>e.trim().split(`:`)[0].trim()).filter(Boolean);n.push({source:r[2],symbols:e,isRelative:r[2].startsWith(`.`)})}break}case`.java`:case`.kt`:case`.scala`:{let t=/^import\s+(?:static\s+)?([\w.]+)\s*;/gm,r;for(;(r=t.exec(e))!==null;){let t=r[1].split(`.`),i=t[t.length-1];i===`*`?n.push({source:r[1],symbols:[],isRelative:V(r[1],e)}):n.push({source:r[1],symbols:[i],isRelative:V(r[1],e)})}break}case`.py`:{let t=/^from\s+([\w.]+)\s+import\s+(.+)$/gm,r;for(;(r=t.exec(e))!==null;){let e=r[2].split(`,`).map(e=>{let t=e.trim().split(/\s+as\s+/);return(t[t.length-1]||``).trim()}).filter(e=>e&&e!==`(`);n.push({source:r[1],symbols:e,isRelative:r[1].startsWith(`.`)})}let i=/^import\s+([\w.]+)(?:\s+as\s+(\w+))?\s*$/gm;for(;(r=i.exec(e))!==null;){let e=r[1].split(`.`),t=r[2]||e[e.length-1];n.push({source:r[1],symbols:[t],isRelative:r[1].startsWith(`.`)})}break}case`.go`:{let t=/import\s+(?:(\w+)\s+)?[""]([^""]+)[""]/g,r;for(;(r=t.exec(e))!==null;){let e=r[2].split(`/`),t=r[1]||e[e.length-1];n.push({source:r[2],symbols:[t],isRelative:!r[2].includes(`.`)&&!r[2].startsWith(`github.com`)})}let i=/import\s*\(([\s\S]*?)\)/g;for(;(r=i.exec(e))!==null;){let e=r[1],t=/(?:(\w+)\s+)?[""]([^""]+)[""]/g,i;for(;(i=t.exec(e))!==null;){let e=i[2].split(`/`),t=i[1]||e[e.length-1];n.push({source:i[2],symbols:[t],isRelative:!i[2].includes(`.`)&&!i[2].startsWith(`github.com`)})}}break}case`.cs`:{let t=/^using\s+(?:static\s+)?([\w.]+)\s*;/gm,r;for(;(r=t.exec(e))!==null;){let e=r[1].split(`.`);n.push({source:r[1],symbols:[e[e.length-1]],isRelative:!0})}break}case`.rs`:{let t=/^use\s+([\w:]+(?:::\w+)*)/gm,r;for(;(r=t.exec(e))!==null;){let e=r[1].split(`::`),t=e[e.length-1];n.push({source:r[1],symbols:t===`*`?[]:[t],isRelative:r[1].startsWith(`crate`)||r[1].startsWith(`super`)})}break}}return n}function me(e,t){let n=new Set;switch(t){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:{let t=/export\s+(?:default\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\s+(\w+)/g,r;for(;(r=t.exec(e))!==null;)n.add(r[1]);break}case`.java`:case`.kt`:case`.scala`:{let t=/(?:public|protected)\s+(?:static\s+)?(?:abstract\s+)?(?:final\s+)?(?:class|interface|enum|record|@interface)\s+(\w+)/g,r;for(;(r=t.exec(e))!==null;)n.add(r[1]);let i=/(?:public|protected)\s+(?:static\s+)?(?:abstract\s+)?(?:final\s+)?\w+(?:<[^>]+>)?\s+(\w+)\s*\(/g;for(;(r=i.exec(e))!==null;)[`if`,`for`,`while`,`switch`,`catch`,`return`,`class`,`interface`,`enum`,`new`].includes(r[1])||n.add(r[1]);break}case`.py`:{let t=/^(?:def|class)\s+([A-Z_]\w*)/gm,r;for(;(r=t.exec(e))!==null;)r[1].startsWith(`_`)||n.add(r[1]);break}case`.go`:{let t=/^(?:func|type|var|const)\s+(\(?[A-Z]\w*)/gm,r;for(;(r=t.exec(e))!==null;)n.add(r[1].replace(`(`,``));break}}return n}function V(e,t){let n=t.match(/^package\s+([\w.]+)\s*;/m);if(!n)return!1;let r=n[1].split(`.`),i=e.split(`.`);return r.length>=2&&i.length>=2&&r[0]===i[0]&&r[1]===i[1]}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function he(e,t){switch(t){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:return e.replace(/^import\s+.+$/gm,``).replace(/^const\s+.+=\s*require\(.+$/gm,``);case`.java`:case`.kt`:case`.scala`:return e.replace(/^import\s+.+;$/gm,``);case`.py`:return e.replace(/^(?:from\s+.+import\s+.+|import\s+.+)$/gm,``);case`.go`:return e.replace(/^import\s+.+$/gm,``).replace(/import\s*\([\s\S]*?\)/g,``);case`.cs`:return e.replace(/^using\s+.+;$/gm,``);case`.rs`:return e.replace(/^use\s+.+;$/gm,``);default:return e}}function ge(e,t){let n=new Map;for(let r of e){let e=c(t,r).replace(/\\/g,`/`),i=e.replace(/\.[^.]+$/,``);U(n,i,e);let a=i.split(`/`),o=a[a.length-1];U(n,o,e)}return n}function U(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function _e(e,t,n,r){switch(r){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:{if(!t.startsWith(`.`))return[];let r=e.split(`/`).slice(0,-1).join(`/`),i=W(r?`${r}/${t}`:t);for(let e of[``,`.ts`,`.tsx`,`.js`,`.jsx`,`/index.ts`,`/index.js`]){let t=n.get(i+e)||n.get((i+e).replace(/\.[^.]+$/,``));if(t&&t.length>0)return[t[0]]}let a=n.get(i.replace(/\.[^.]+$/,``));return a?[a[0]]:[]}case`.java`:case`.kt`:case`.scala`:{let e=t.split(`.`),r=e[e.length-1];if(r===`*`)return[];let i=n.get(r);return i?[i[0]]:[]}case`.py`:{if(t.startsWith(`.`)){let r=e.split(`/`).slice(0,-1).join(`/`),i=t.replace(/^\.+/,``).replace(/\./g,`/`),a=r?`${r}/${i}`:i,o=a.split(`/`),s=n.get(a)||n.get(o[o.length-1]);if(s)return[s[0]]}let r=t.replace(/\./g,`/`),i=n.get(r);return i?[i[0]]:[]}case`.go`:{let e=t.split(`/`),r=e[e.length-1],i=n.get(r);return i?[i[0]]:[]}default:return[]}}function W(e){let t=e.split(`/`),n=[];for(let e of t)if(!(e===`.`||e===``)){if(e===`..`){n.pop();continue}n.push(e)}return n.join(`/`)}function G(e){return e.split(`/`).some(e=>e===`test`||e===`tests`||e===`__tests__`||e===`spec`||e===`test_`||e===`__test__`)||/\.(test|spec)\.[^.]+$/.test(e)}function ve(e){let t=[],n=(r,i)=>{if(!(i>10))try{for(let a of y(r,{withFileTypes:!0})){if(L.has(a.name)||a.name.startsWith(`.`))continue;let l=s(r,a.name);if(a.isDirectory())n(l,i+1);else{let n=o(a.name).toLowerCase();if(!R.has(n)||a.name.endsWith(`.d.ts`)||/\.(test|spec)\.[^.]+$/.test(a.name)||c(e,r).replace(/\\/g,`/`).split(`/`).some(e=>e===`test`||e===`tests`||e===`__tests__`||e===`spec`))continue;t.push(l)}}}catch{}};return n(e,0),t}function ye(e){let t=new Map;for(let n of[`packages`,`apps`,`libs`,`services`,`functions`]){let r=s(e,n),i;try{i=y(r,{withFileTypes:!0})}catch{continue}for(let e of i){if(!e.isDirectory())continue;let i=s(r,e.name,`package.json`);try{let r=JSON.parse(v(i,`utf-8`));if(r.name){let i=r.exports?.[`.`]?.import??r.exports?.[`.`]?.default??r.main??`src/index.ts`,a=s(n,e.name,i).replace(/\\/g,`/`);t.set(r.name,a)}}catch{}}}return t}function be(e,t,n){if(t.has(e))return t.get(e)??null;let r=e.startsWith(`@`)?e.split(`/`):[];if(r.length>=2){let e=`${r[0]}/${r[1]}`,i=t.get(e);if(i){if(r.length===2)return i;let e=i.replace(/\/src\/index\.\w+$/,``).replace(/\/dist\/.*$/,``),t=r.slice(2).join(`/`),a=[`${e}/src/${t}`,`${e}/${t}`];for(let e of a){let t=e.replace(/\.\w+$/,``),r=n.get(t);if(r?.[0])return r[0]}return i}}return null}const K=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.rb`,`.kt`,`.scala`,`.rs`,`.php`,`.swift`]),xe=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),q={exported:[{pattern:/^export\s+(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^export\s+(?:default\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^export\s+interface\s+(\w+)/gm,kind:`interface`},{pattern:/^export\s+type\s+(\w+)/gm,kind:`type`},{pattern:/^export\s+(?:const|let)\s+(\w+)/gm,kind:`const`},{pattern:/^export\s+enum\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^type\s+(\w+)/gm,kind:`type`},{pattern:/^(?:const|let)\s+(\w+)\s*=/gm,kind:`const`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}]},Se={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:abstract\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*[;=]/gm,kind:`variable`}],skipIndentFilter:!0},Ce={exported:[{pattern:/^def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^async\s+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`}],local:[{pattern:/^[ \t]+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]+async\s+def\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},we={exported:[{pattern:/^func\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([A-Z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([A-Z]\w*)\s+interface\b/gm,kind:`interface`},{pattern:/^type\s+([A-Z]\w*)\s+/gm,kind:`type`}],local:[{pattern:/^func\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([a-z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([a-z]\w*)\s+/gm,kind:`type`}],skipIndentFilter:!0},Te={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:partial\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:virtual\s+)?(?:override\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])?)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},Ee={exported:[{pattern:/^(?:open\s+|data\s+|sealed\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^(?:fun|suspend\s+fun)\s+(\w+)\s*[(<]/gm,kind:`function`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^object\s+(\w+)/gm,kind:`class`},{pattern:/^enum\s+class\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^[ \t]+(?:private|internal)\s+(?:fun|suspend\s+fun)\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]+(?:private|internal)\s+(?:val|var)\s+(\w+)/gm,kind:`variable`}],skipIndentFilter:!0},De={exported:[{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^module\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]+def\s+self\.(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]+def\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},Oe={exported:[{pattern:/^pub\s+(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^pub\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^pub\s+trait\s+(\w+)/gm,kind:`interface`},{pattern:/^pub\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^pub\s+type\s+(\w+)/gm,kind:`type`}],local:[{pattern:/^(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^struct\s+(\w+)/gm,kind:`class`},{pattern:/^trait\s+(\w+)/gm,kind:`interface`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}],skipIndentFilter:!0},ke={exported:[{pattern:/^[ \t]*(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^function\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},Ae={exported:[{pattern:/^[ \t]*(?:open|public)\s+class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+protocol\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*(?:open|public)\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*(?:open|public)\s+func\s+(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+func\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+class\s+(\w+)/gm,kind:`class`}],skipIndentFilter:!0},je={exported:[{pattern:/^[ \t]*(?:case\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*object\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*trait\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*def\s+(\w+)/gm,kind:`function`}],local:[],skipIndentFilter:!0};function Me(e){switch(e){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:return q;case`.java`:return Se;case`.py`:return Ce;case`.go`:return we;case`.cs`:return Te;case`.kt`:return Ee;case`.rb`:return De;case`.rs`:return Oe;case`.php`:return ke;case`.swift`:return Ae;case`.scala`:return je;default:return q}}function J(e,t){let n=``,r=0,i=!1;for(let a=t;a<Math.min(t+5,e.length);a++){let t=e[a].trim();n+=(n?` `:``)+t;for(let e of t)e===`(`&&(r++,i=!0),e===`)`&&r--;if(i&&r<=0)return n.replace(/\s*\{.*$/,``).replace(/\s*:\s*$/,``).trim()}return n.trim()||void 0}function Y(e,t){let n=J(e,t);if(!n)return;let r=n.match(/\)\s*:\s*([^{=]+)/);if(r)return r[1].trim().slice(0,200)||void 0;let i=n.match(/=>\s*([^{]+)/);if(i)return i[1].trim().slice(0,200)||void 0}function X(e,t){for(let n=t-1;n>=Math.max(0,t-10);n--){let t=e[n].trim();if(t!==``){if(t.endsWith(`*/`)){for(let t=n;t>=Math.max(0,n-20);t--)if(e[t].trim().startsWith(`/**`)||e[t].trim().startsWith(`/*`)){for(let r=t;r<=n;r++){let t=e[r].replace(/^\s*\/\*\*?\s*/,``).replace(/\s*\*\/\s*$/,``).replace(/^\s*\*\s?/,``).trim();if(t.length>0&&!t.startsWith(`@`))return t.slice(0,200)}return}}if(t.startsWith(`//`))return t.replace(/^\/\/\s*/,``).slice(0,200)||void 0;break}}}function Z(e,t){let n=``,r=0,i=!1;for(let a=t;a<Math.min(t+30,e.length);a++){let t=e[a];n+=` ${t.trim()}`;for(let e of t)e===`{`&&(r++,i=!0),e===`}`&&r--;if(i&&r<=0){let e=n.match(/\{([\s\S]*)\}/);if(e){let t=`{ ${e[1].replace(/\n\s*/g,` `).replace(/\s+/g,` `).trim()} }`;return t.length>500?`${t.slice(0,500)}…`:t}return}}}var Ne=class{name=`symbols`;async analyze(e,n={}){let{format:r=`markdown`,filter:i}=n,s=Date.now(),l=await this.collectFiles(e),f=l.length===1&&l[0]===e?a(e):e,p=[],h=[],_=!1;try{await d.ensure(),_=!0}catch{}for(let e of l){let n=await t(e,`utf-8`),r=c(f,e).replace(/\\/g,`/`),i=o(e);if(_&&u.has(i)){let e=await g(n,i,r);if(e.length>0){p.push(...e);let t=await m(n,i,r);h.push(...t)}else{let e=this.extractSymbolsRegex(n,r);p.push(...e)}}else{let e=this.extractSymbolsRegex(n,r);p.push(...e)}}if(i){let e=i.toLowerCase();p=p.filter(t=>t.name.toLowerCase().includes(e))}return{output:r===`json`?JSON.stringify(p,null,2):this.formatMarkdown(p,f,h),data:{symbols:p,byKind:this.groupByKind(p),exportedCount:p.filter(e=>e.exported).length,totalCount:p.length,callEdges:h},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:l.length,durationMs:Date.now()-s}}}async collectFiles(e){let t=[],i;try{i=await r(e)}catch{throw Error(`Path does not exist: ${e}`)}if(i.isFile()){if(K.has(o(e)))return[e];throw Error(`Not a recognized source file: ${e}`)}if(!i.isDirectory())throw Error(`Not a file or directory: ${e}`);let a=async e=>{let r=await n(e,{withFileTypes:!0});for(let n of r){if(xe.has(n.name)||n.name.startsWith(`.`))continue;let r=s(e,n.name);n.isDirectory()?await a(r):K.has(o(n.name))&&t.push(r)}};return await a(e),t}extractSymbolsRegex(e,t){let n=[],r=e.split(`
47
47
  `),i=new Set,a=Me(o(t));for(let{pattern:o,kind:s}of a.exported){let a=new RegExp(o.source,o.flags),c;for(;(c=a.exec(e))!==null;){let a=c[1];i.add(a);let o=e.slice(0,c.index).split(`
@@ -9,7 +9,7 @@ Dead in docs (informational):`);for(let t of e.deadInDocs)console.log(` - ${t.p
9
9
  Actions: stats, find-nodes, find-edges, neighbors, traverse, delete, clear`),process.exit(1));let{graphStore:n}=await Y(),r=N(e,`--type`,``),i=N(e,`--name`,``),a=N(e,`--node-id`,``),o=N(e,`--edge-type`,``),s=N(e,`--direction`,`both`),c=M(e,`--depth`,2),l=M(e,`--limit`,50),u=N(e,`--source-path`,``),d={stats:`stats`,"find-nodes":`find_nodes`,"find-edges":`find_edges`,neighbors:`neighbors`,traverse:`traverse`,delete:`delete`,clear:`clear`}[t];d||(console.error(`Unknown graph action: ${t}`),console.error(`Actions: stats, find-nodes, find-edges, neighbors, traverse, delete, clear`),process.exit(1));let f=await ge(n,{action:d,nodeType:r||void 0,namePattern:i||void 0,sourcePath:u||void 0,nodeId:a||void 0,edgeType:o||void 0,direction:s,maxDepth:c,limit:l});if(console.log(f.summary),f.nodes&&f.nodes.length>0){console.log(`
10
10
  Nodes:`);for(let e of f.nodes){let t=Object.keys(e.properties).length>0?` ${JSON.stringify(e.properties)}`:``;console.log(` ${e.name} (${e.type}, id: ${e.id})${t}`)}}if(f.edges&&f.edges.length>0){console.log(`
11
11
  Edges:`);for(let e of f.edges){let t=e.weight===1?``:` (weight: ${e.weight})`;console.log(` ${e.fromId} --[${e.type}]--> ${e.toId}${t}`)}}f.stats&&(console.log(`\nNode types: ${JSON.stringify(f.stats.nodeTypes)}`),console.log(`Edge types: ${JSON.stringify(f.stats.edgeTypes)}`)),f.deleted!==void 0&&console.log(`Deleted: ${f.deleted}`)}}],Ot=[{name:`remember`,description:`Store curated knowledge`,usage:`aikit remember <title> --category <cat> [--tags tag1,tag2]`,run:async e=>{let t=N(e,`--category`,``).trim(),n=I(N(e,`--tags`,``)),r=e.shift()?.trim()??``,i=await F(),a=i.trim().length>0?i:e.join(` `).trim();(!r||!t||!a.trim())&&(console.error(`Usage: aikit remember <title> --category <cat> [--tags tag1,tag2]`),process.exit(1));let{curated:o}=await Y(),s=await o.remember(r,a,t,n);console.log(`Stored curated entry`),console.log(` Path: ${s.path}`),console.log(` Category: ${t}`),n.length>0&&console.log(` Tags: ${n.join(`, `)}`)}},{name:`forget`,description:`Remove a curated entry`,usage:`aikit forget <path> --reason <reason>`,run:async e=>{let t=N(e,`--reason`,``).trim(),n=e.shift()?.trim()??``;(!n||!t)&&(console.error(`Usage: aikit forget <path> --reason <reason>`),process.exit(1));let{curated:r}=await Y(),i=await r.forget(n,t);console.log(`Removed curated entry: ${i.path}`)}},{name:`read`,description:`Read a curated entry`,usage:`aikit read <path>`,run:async e=>{let t=e.shift()?.trim()??``;t||(console.error(`Usage: aikit read <path>`),process.exit(1));let{curated:n}=await Y(),r=await n.read(t);console.log(r.title),console.log(`─`.repeat(60)),console.log(`Path: ${r.path}`),console.log(`Category: ${r.category}`),console.log(`Version: ${r.version}`),console.log(`Tags: ${r.tags.length>0?r.tags.join(`, `):`None`}`),console.log(``),console.log(r.content)}},{name:`list`,description:`List curated entries`,usage:`aikit list [--category <cat>] [--tag <tag>]`,run:async e=>{let t=N(e,`--category`,``).trim()||void 0,n=N(e,`--tag`,``).trim()||void 0,{curated:r}=await Y(),i=await r.list({category:t,tag:n});if(i.length===0){console.log(`No curated entries found.`);return}console.log(`Curated entries (${i.length})`),console.log(`─`.repeat(60));for(let e of i){console.log(e.path),console.log(` ${e.title}`),console.log(` Category: ${e.category} | Version: ${e.version}`),console.log(` Tags: ${e.tags.length>0?e.tags.join(`, `):`None`}`);let t=e.contentPreview.replace(/\s+/g,` `).trim();t&&console.log(` Preview: ${t}`),console.log(``)}}},{name:`update`,description:`Update a curated entry`,usage:`aikit update <path> --reason <reason>`,run:async e=>{let t=N(e,`--reason`,``).trim(),n=e.shift()?.trim()??``,r=await F();(!n||!t||!r.trim())&&(console.error(`Usage: aikit update <path> --reason <reason>`),process.exit(1));let{curated:i}=await Y(),a=await i.update(n,r,t);console.log(`Updated curated entry`),console.log(` Path: ${a.path}`),console.log(` Version: ${a.version}`)}},{name:`compact`,description:`Compress text for context`,usage:`aikit compact <query> [--path <file>] [--max-chars N] [--segmentation paragraph|sentence|line]`,run:async e=>{let t=M(e,`--max-chars`,3e3),n=N(e,`--path`,``).trim()||void 0,r=N(e,`--segmentation`,`paragraph`),i=e.join(` `).trim(),a=n?void 0:await F();(!i||!n&&!a?.trim())&&(console.error(`Usage: aikit compact <query> --path <file> OR cat file | aikit compact <query>`),process.exit(1));let{embedder:o}=await Y(),s=await ie(o,{text:a,path:n,query:i,maxChars:t,segmentation:r});console.log(`Compressed ${s.originalChars} chars to ${s.compressedChars} chars`),console.log(`Ratio: ${(s.ratio*100).toFixed(1)}% | Segments: ${s.segmentsKept}/${s.segmentsTotal}`),console.log(``),console.log(s.text)}}],kt=[{name:`search`,description:`Search the AI Kit index`,usage:`aikit search <query> [--limit N] [--mode hybrid|semantic|keyword] [--graph-hops 0-3]`,run:async e=>{let t=M(e,`--limit`,5),n=N(e,`--mode`,`hybrid`),r=M(e,`--graph-hops`,0),i=e.join(` `).trim();i||(console.error(`Usage: aikit search <query>`),process.exit(1));let{embedder:a,store:o,graphStore:s}=await Y(),c=await a.embedQuery(i),l;if(n===`keyword`)l=await o.ftsSearch(i,{limit:t});else if(n===`semantic`)l=await o.search(c,{limit:t});else{let[e,n]=await Promise.all([o.search(c,{limit:t*2}),o.ftsSearch(i,{limit:t*2}).catch(()=>[])]);l=U(e,n).slice(0,t)}if(l.length===0){console.log(`No results found.`);return}for(let{record:e,score:t}of l){console.log(`\n${`─`.repeat(60)}`),console.log(`[${(t*100).toFixed(1)}%] ${e.sourcePath}:${e.startLine}-${e.endLine}`),console.log(` Type: ${e.contentType} | Origin: ${e.origin}`),e.tags.length>0&&console.log(` Tags: ${e.tags.join(`, `)}`),console.log(``);let n=e.content.length>500?`${e.content.slice(0,500)}...`:e.content;console.log(n)}if(console.log(`\n${`─`.repeat(60)}`),console.log(`${l.length} result(s) found.`),r>0&&l.length>0)try{let{graphAugmentSearch:e}=await import(`../../tools/dist/index.js`),t=(await e(s,l.map(e=>({recordId:e.record.id,score:e.score,sourcePath:e.record.sourcePath})),{hops:r,maxPerHit:5})).filter(e=>e.graphContext.nodes.length>0);if(t.length>0){console.log(`\nGraph context (${r} hop${r>1?`s`:``}):\n`);for(let e of t){console.log(` ${e.sourcePath}:`);for(let t of e.graphContext.nodes.slice(0,5))console.log(` → ${t.name} (${t.type})`);for(let t of e.graphContext.edges.slice(0,5))console.log(` → ${t.fromId} --[${t.type}]--> ${t.toId}`)}}}catch(e){console.error(`[graph] augmentation failed: ${e.message}`)}}},{name:`find`,description:`Run federated search across indexed content and files`,usage:`aikit find [query] [--glob <pattern>] [--pattern <regex>] [--limit N]`,run:async e=>{let t=M(e,`--limit`,10),n=N(e,`--glob`,``).trim()||void 0,r=N(e,`--pattern`,``).trim()||void 0,i=e.join(` `).trim()||void 0;!i&&!n&&!r&&(console.error(`Usage: aikit find [query] [--glob <pattern>] [--pattern <regex>] [--limit N]`),process.exit(1));let{embedder:a,store:o}=await Y(),s=await g(a,o,{query:i,glob:n,pattern:r,limit:t});if(s.results.length===0){console.log(`No matches found.`);return}console.log(`Strategies: ${s.strategies.join(`, `)}`),console.log(`Results: ${s.results.length} shown (${s.totalFound} total)`);for(let e of s.results){let t=e.lineRange?`:${e.lineRange.start}-${e.lineRange.end}`:``;console.log(`\n[${e.source}] ${e.path}${t}`),console.log(` Score: ${(e.score*100).toFixed(1)}%`),e.preview&&console.log(` ${e.preview.replace(/\s+/g,` `).trim()}`)}}},{name:`scope-map`,description:`Generate a reading plan for a task`,usage:`aikit scope-map <task> [--max-files N]`,run:async e=>{let t=M(e,`--max-files`,15),n=e.join(` `).trim();n||(console.error(`Usage: aikit scope-map <task> [--max-files N]`),process.exit(1));let{embedder:r,store:i}=await Y(),a=await Fe(r,i,{task:n,maxFiles:t});console.log(`Task: ${a.task}`),console.log(`Files: ${a.files.length}`),console.log(`Estimated tokens: ${a.totalEstimatedTokens}`),console.log(``),console.log(`Reading order:`);for(let e of a.readingOrder)console.log(` ${e}`);for(let[e,t]of a.files.entries())console.log(`\n${e+1}. ${t.path}`),console.log(` Relevance: ${(t.relevance*100).toFixed(1)}% | Tokens: ${t.estimatedTokens}`),console.log(` Why: ${t.reason}`),t.focusRanges.length>0&&console.log(` Focus: ${at(t.focusRanges)}`)}},{name:`symbol`,description:`Resolve a symbol definition, imports, and references`,usage:`aikit symbol <name> [--limit N]`,run:async e=>{let t=M(e,`--limit`,20),n=e.join(` `).trim();n||(console.error(`Usage: aikit symbol <name> [--limit N]`),process.exit(1));let{embedder:r,store:i}=await Y();ht(await Ve(r,i,{name:n,limit:t}))}},{name:`trace`,description:`Trace forward/backward flow for a symbol or file location`,usage:`aikit trace <start> [--direction forward|backward|both] [--max-depth N]`,run:async e=>{let t=N(e,`--direction`,`both`).trim()||`both`,n=M(e,`--max-depth`,3),r=e.join(` `).trim();(!r||![`forward`,`backward`,`both`].includes(t))&&(console.error(`Usage: aikit trace <start> [--direction forward|backward|both] [--max-depth N]`),process.exit(1));let{embedder:i,store:a}=await Y();dt(await Ue(i,a,{start:r,direction:t,maxDepth:n}))}},{name:`examples`,description:`Find real code examples of a symbol or pattern`,usage:`aikit examples <query> [--limit N] [--content-type type]`,run:async e=>{let t=M(e,`--limit`,5),n=N(e,`--content-type`,``).trim()||void 0,r=e.join(` `).trim();r||(console.error(`Usage: aikit examples <query> [--limit N] [--content-type type]`),process.exit(1));let{embedder:i,store:a}=await Y();ft(await pe(i,a,{query:r,limit:t,contentType:n}))}},{name:`dead-symbols`,description:`Find exported symbols that appear to be unused`,usage:`aikit dead-symbols [--limit N]`,run:async e=>{let t=M(e,`--limit`,100),{embedder:n,store:r}=await Y();pt(await fe(n,r,{limit:t}))}},{name:`lookup`,description:`Look up indexed content by record ID or source path`,usage:`aikit lookup <id>`,run:async e=>{let t=e.join(` `).trim();t||(console.error(`Usage: aikit lookup <id>`),process.exit(1));let{store:n}=await Y(),r=await n.getById(t);if(r){console.log(r.id),console.log(`─`.repeat(60)),console.log(`Path: ${r.sourcePath}`),console.log(`Chunk: ${r.chunkIndex+1}/${r.totalChunks}`),console.log(`Lines: ${r.startLine}-${r.endLine}`),console.log(`Type: ${r.contentType} | Origin: ${r.origin}`),r.tags.length>0&&console.log(`Tags: ${r.tags.join(`, `)}`),console.log(``),console.log(r.content);return}let i=await n.getBySourcePath(t);if(i.length===0){console.log(`No indexed content found for: ${t}`);return}i.sort((e,t)=>e.chunkIndex-t.chunkIndex),console.log(t),console.log(`─`.repeat(60)),console.log(`Chunks: ${i.length} | Type: ${i[0].contentType}`);for(let e of i){let t=e.startLine?` (lines ${e.startLine}-${e.endLine})`:``;console.log(`\nChunk ${e.chunkIndex+1}/${e.totalChunks}${t}`),console.log(e.content)}}}],X=s(u(import.meta.url));function Z(e){let t=e;for(let e=0;e<10;e++){try{let e=c(t,`package.json`);if(r(e)&&JSON.parse(a(e,`utf8`)).name===`@vpxa/aikit`)return t}catch{}let e=s(t);if(e===t)break;t=e}return l(e,`..`,`..`,`..`)}const At=[{name:`status`,description:`Show AI Kit index status and statistics`,run:async()=>{let{isUserInstalled:e,getGlobalDataDir:t,computePartitionKey:n,listWorkspaces:r}=await import(`../../core/dist/index.js`),{existsSync:i}=await import(`node:fs`),a=process.cwd(),o=e(),s=i(l(a,`.vscode`,`mcp.json`)),c,u;if(o&&s)c=`workspace (overrides user-level for this workspace)`,u=l(a,`.aikit-data`);else if(o){let e=n(a);c=i(l(a,`AGENTS.md`))?`user (workspace scaffolded)`:`user (workspace not scaffolded)`,u=l(t(),e)}else c=`workspace`,u=l(a,`.aikit-data`);if(console.log(`AI Kit Status`),console.log(`─`.repeat(40)),console.log(` Mode: ${c}`),console.log(` Data: ${u}`),o&&!s){let e=r();console.log(` Registry: ${e.length} workspace(s) enrolled`)}try{let{store:e}=await Y(),t=await e.getStats(),n=await e.listSourcePaths();console.log(` Records: ${t.totalRecords}`),console.log(` Files: ${t.totalFiles}`),console.log(` Indexed: ${t.lastIndexedAt??`Never`}`),console.log(` Backend: ${t.storeBackend}`),console.log(` Model: ${t.embeddingModel}`),console.log(``),console.log(`Content Types:`);for(let[e,n]of Object.entries(t.contentTypeBreakdown))console.log(` ${e}: ${n}`);if(n.length>0){console.log(``),console.log(`Files (${n.length} total):`);for(let e of n.slice(0,20))console.log(` ${e}`);n.length>20&&console.log(` ... and ${n.length-20} more`)}}catch{console.log(``),console.log(" Index not available — run `aikit reindex` to index this workspace.")}o&&!s&&!i(l(a,`AGENTS.md`))&&(console.log(``),console.log(" Action: Run `npx @vpxa/aikit init` to add AGENTS.md and copilot-instructions.md"))}},{name:`reindex`,description:`Re-index the AI Kit index from configured sources`,usage:`aikit reindex [--full]`,run:async e=>{let t=e.includes(`--full`),{store:n,indexer:r,curated:i,config:a}=await Y();console.log(`Indexing sources...`);let o=e=>{e.phase===`chunking`&&e.currentFile&&process.stdout.write(`\r [${e.filesProcessed+1}/${e.filesTotal}] ${e.currentFile}`),e.phase===`done`&&process.stdout.write(`
12
- `)},s;t?(console.log(`Dropping existing index for full reindex...`),s=await r.reindexAll(a,o)):s=await r.index(a,o),console.log(`Done: ${s.filesProcessed} files, ${s.chunksCreated} chunks in ${(s.durationMs/1e3).toFixed(1)}s`),console.log(`Building FTS index...`),await n.createFtsIndex(),console.log(`Re-indexing curated entries...`);let c=await i.reindexAll();console.log(`Curated: ${c.indexed} entries restored`)}},{name:`serve`,description:`Start the MCP server (stdio or HTTP)`,usage:`aikit serve [--transport stdio|http] [--port N]`,run:async e=>{let t=l(Z(X),`packages`,`server`,`dist`,`index.js`),n=N(e,`--transport`,`stdio`),r=N(e,`--port`,`3210`),i=tt(t,[],{stdio:n===`stdio`?[`pipe`,`pipe`,`inherit`,`ipc`]:`inherit`,env:{...process.env,AIKIT_TRANSPORT:n,AIKIT_PORT:r}});n===`stdio`&&i.stdin&&i.stdout&&(process.stdin.pipe(i.stdin),i.stdout.pipe(process.stdout)),i.on(`exit`,e=>process.exit(e??0)),process.on(`SIGINT`,()=>i.kill(`SIGINT`)),process.on(`SIGTERM`,()=>i.kill(`SIGTERM`)),await new Promise(()=>{})}},{name:`init`,description:`Initialize AI Kit in the current directory`,usage:`aikit init [--workspace] [--smart] [--force] [--guide]`,run:async e=>{let t=e.includes(`--user`),n=e.includes(`--workspace`),r=e.includes(`--smart`),i=e.includes(`--guide`),a=e.includes(`--force`);if(t&&n&&(console.error(`Cannot use --user and --workspace together.`),process.exit(1)),i){let{guideProject:e}=await import(`./init-CVtbu7zj.js`);await e();return}if(r){let{initSmart:e}=await import(`./init-CVtbu7zj.js`);await e({force:a})}else if(t){let{initUser:e}=await import(`./user-Dj8KE0_0.js`);await e({force:a})}else if(n){let{initProject:e}=await import(`./init-CVtbu7zj.js`);await e({force:a})}else{let{initUser:e}=await import(`./user-Dj8KE0_0.js`);await e({force:a})}}},{name:`check`,description:`Run incremental typecheck and lint`,usage:`aikit check [--cwd <dir>] [--files f1,f2] [--skip-types] [--skip-lint] [--detail efficient|normal|full]`,run:async e=>{let t=N(e,`--cwd`,``).trim()||void 0,n=N(e,`--files`,``),r=N(e,`--detail`,`full`)||`full`,i=n.split(`,`).map(e=>e.trim()).filter(Boolean),a=!1;e.includes(`--skip-types`)&&(e.splice(e.indexOf(`--skip-types`),1),a=!0);let o=!1;e.includes(`--skip-lint`)&&(e.splice(e.indexOf(`--skip-lint`),1),o=!0);let s=await m({cwd:t,files:i.length>0?i:void 0,skipTypes:a,skipLint:o,detail:r});st(s),s.passed||(process.exitCode=1)}},{name:`batch`,description:`Execute built-in operations from JSON input`,usage:`aikit batch [--file path] [--concurrency N]`,run:async e=>{let t=N(e,`--file`,``).trim()||void 0,n=(()=>{let t=e.indexOf(`--concurrency`);if(t===-1||t+1>=e.length)return 0;let n=Number.parseInt(e.splice(t,2)[1],10);return Number.isNaN(n)?0:n})(),r=await rt(t);r.trim()||(console.error(`Usage: aikit batch [--file path] [--concurrency N]`),process.exit(1));let i=it(r),a=n>0?n:i.concurrency,o=i.operations.some(e=>e.type!==`check`)?await Y():null,s=await p(i.operations,async e=>vt(e,o),{concurrency:a});console.log(JSON.stringify(s,null,2)),s.some(e=>e.status===`error`)&&(process.exitCode=1)}},{name:`health`,description:`Run project health checks on the current directory`,usage:`aikit health [path]`,run:async e=>{let t=ve(e.shift());console.log(`Project Health: ${t.path}`),console.log(`─`.repeat(50));for(let e of t.checks){let t=e.status===`pass`?`+`:e.status===`warn`?`~`:`X`;console.log(` [${t}] ${e.name}: ${e.message}`)}console.log(`─`.repeat(50)),console.log(`Score: ${t.score}% — ${t.summary}`)}},{name:`audit`,description:`Run a unified project audit (structure, deps, patterns, health, dead symbols, check)`,usage:`aikit audit [path] [--checks structure,dependencies,patterns,health,dead_symbols,check,entry_points] [--detail efficient|normal|full]`,run:async e=>{let{store:t,embedder:n}=await Y(),r=N(e,`--detail`,`efficient`)||`efficient`,i=N(e,`--checks`,``),a=i?i.split(`,`).map(e=>e.trim()):void 0,o=await f(t,n,{path:e.shift()||`.`,checks:a,detail:r});if(o.ok){if(console.log(o.summary),o.next&&o.next.length>0){console.log(`
13
- Suggested next steps:`);for(let e of o.next)console.log(` → ${e.tool}: ${e.reason}`)}}else console.error(o.error?.message??`Audit failed`),process.exitCode=1}},{name:`guide`,description:`Tool discovery — recommend AI Kit tools for a given goal`,usage:`aikit guide <goal> [--max N]`,run:async e=>{let t=e.indexOf(`--max`),n=5;t!==-1&&t+1<e.length&&(n=Number.parseInt(e.splice(t,2)[1],10)||5);let r=e.join(` `).trim();r||(console.error(`Usage: aikit guide <goal> [--max N]`),console.error(`Example: aikit guide "audit this project"`),process.exit(1));let i=_e(r,n);console.log(`Workflow: ${i.workflow}`),console.log(` ${i.description}\n`),console.log(`Recommended tools:`);for(let e of i.tools){let t=e.suggestedArgs?` ${JSON.stringify(e.suggestedArgs)}`:``;console.log(` ${e.order}. ${e.tool} — ${e.reason}${t}`)}i.alternativeWorkflows.length>0&&console.log(`\nAlternatives: ${i.alternativeWorkflows.join(`, `)}`)}},{name:`replay`,description:`Show recent tool invocation audit trail`,usage:`aikit replay [--last N] [--tool <name>] [--source mcp|cli]`,run:async e=>{let t=Me({last:Number.parseInt(e[e.indexOf(`--last`)+1],10)||20,tool:e.includes(`--tool`)?e[e.indexOf(`--tool`)+1]:void 0,source:e.includes(`--source`)?e[e.indexOf(`--source`)+1]:void 0});if(t.length===0){console.log(`No replay entries. Activity is logged when tools are invoked.`);return}console.log(`Replay Log (${t.length} entries)\n`);for(let e of t){let t=e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts,n=e.status===`ok`?`✓`:`✗`;console.log(`${t} ${n} ${e.tool} (${e.durationMs}ms) [${e.source}]`),console.log(` in: ${e.input}`),console.log(` out: ${e.output}`)}Ne().catch(()=>{})}},{name:`replay-clear`,description:`Clear the replay audit trail`,run:async()=>{je(),console.log(`Replay log cleared.`)}},{name:`dashboard`,description:`Launch web dashboard for knowledge graph visualization`,usage:`aikit dashboard [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=l(Z(X),`packages`,`server`,`dist`,`index.js`),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),u=`http://localhost:${r}/_dashboard/`,d=`http://localhost:${r}/health`,f=!1;for(let e=0;e<30;e+=1){try{if((await fetch(d)).ok){f=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(f||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Dashboard: ${u}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,u],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[u],{stdio:`ignore`,detached:!0}).unref()}let p=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,p),process.on(`SIGTERM`,p),await new Promise(e=>{c.on(`exit`,()=>e())})}},{name:`settings`,description:`Launch web UI to manage AI Kit configuration and environment variables`,usage:`aikit settings [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=l(Z(X),`packages`,`server`,`dist`,`index.js`),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),u=`http://localhost:${r}/settings/`,d=`http://localhost:${r}/health`,f=!1;for(let e=0;e<30;e+=1){try{if((await fetch(d)).ok){f=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(f||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Settings: ${u}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,u],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[u],{stdio:`ignore`,detached:!0}).unref()}let p=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,p),process.on(`SIGTERM`,p),await new Promise(e=>{c.on(`exit`,()=>e())})}}];function jt(e){let t=e;for(let e=0;e<10;e++){try{let e=c(t,`package.json`);if(r(e)&&JSON.parse(a(e,`utf8`)).name===`@vpxa/aikit`)return t}catch{}let e=s(t);if(e===t)break;t=e}return l(e,`..`,`..`,`..`)}const Mt=[{name:`upgrade`,description:`Upgrade AI Kit agents, prompts, and skills to the latest version (user-level and workspace-level)`,usage:`aikit upgrade`,run:async()=>{let{initUser:n}=await import(`./user-Dj8KE0_0.js`);await n({force:!0});let i=process.cwd(),o=r(l(i,`.github`,`.aikit-scaffold.json`)),c=r(l(i,`.github`,`agents`)),d=r(l(i,`.github`,`prompts`)),f=r(l(i,`.claude`,`commands`));if(o||c||d||f){let{initScaffoldOnly:e}=await import(`./init-CVtbu7zj.js`);await e({force:!0})}if(r(l(i,`.github`,`skills`))){let{smartCopySkills:n}=await import(`./scaffold-D664MT9M.js`),r=jt(s(u(import.meta.url))),o=JSON.parse(a(l(r,`package.json`),`utf-8`)).version;await n(i,r,[...e],o,!0);let{smartCopyFlows:c}=await import(`./scaffold-D664MT9M.js`);await c(i,r,[...t],o,!0)}}}],Nt=[{name:`workset`,description:`Manage saved file sets`,usage:`aikit workset <action> [name] [--files f1,f2] [--description desc]`,run:async e=>{let t=e.shift()?.trim(),n=I(N(e,`--files`,``)),r=N(e,`--description`,``).trim()||void 0,i=e.shift()?.trim();switch(t||(console.error(`Usage: aikit workset <action> [name] [--files f1,f2] [--description desc]`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)),t){case`save`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset save <name> --files f1,f2 [--description desc]`),process.exit(1));let e=Pe(i,n,{description:r});console.log(`Saved workset: ${e.name}`),B(e);return}case`get`:{i||(console.error(`Usage: aikit workset get <name>`),process.exit(1));let e=me(i);if(!e){console.log(`No workset found: ${i}`);return}B(e);return}case`list`:{let e=Te();if(e.length===0){console.log(`No worksets saved.`);return}console.log(`Worksets (${e.length})`),console.log(`─`.repeat(60));for(let t of e)B(t),console.log(``);return}case`delete`:{i||(console.error(`Usage: aikit workset delete <name>`),process.exit(1));let e=ce(i);console.log(e?`Deleted workset: ${i}`:`No workset found: ${i}`);return}case`add`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset add <name> --files f1,f2`),process.exit(1));let e=d(i,n);console.log(`Updated workset: ${e.name}`),B(e);return}case`remove`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset remove <name> --files f1,f2`),process.exit(1));let e=ke(i,n);if(!e){console.log(`No workset found: ${i}`);return}console.log(`Updated workset: ${e.name}`),B(e);return}default:console.error(`Unknown workset action: ${t}`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)}}},{name:`stash`,description:`Persist and retrieve named intermediate values`,usage:`aikit stash <set|get|list|delete|clear> [key] [value]`,run:async e=>{let t=e.shift()?.trim(),n=e.shift()?.trim();switch(t||(console.error(`Usage: aikit stash <set|get|list|delete|clear> [key] [value]`),process.exit(1)),t){case`set`:{n||(console.error(`Usage: aikit stash set <key> <value>`),process.exit(1));let t=e.join(` `),r=t.trim()?``:await F(),i=Be(n,gt(t||r));console.log(`Stored stash entry: ${i.key}`),console.log(` Type: ${i.type}`),console.log(` Stored: ${i.storedAt}`);return}case`get`:{n||(console.error(`Usage: aikit stash get <key>`),process.exit(1));let e=Re(n);if(!e){console.log(`No stash entry found: ${n}`);return}console.log(JSON.stringify(e,null,2));return}case`list`:{let e=ze();if(e.length===0){console.log(`No stash entries saved.`);return}console.log(`Stash entries (${e.length})`),console.log(`─`.repeat(60));for(let t of e)console.log(`${t.key} (${t.type})`),console.log(` Stored: ${t.storedAt}`);return}case`delete`:{n||(console.error(`Usage: aikit stash delete <key>`),process.exit(1));let e=Le(n);console.log(e?`Deleted stash entry: ${n}`:`No stash entry found: ${n}`);return}case`clear`:{let e=Ie();console.log(`Cleared ${e} stash entr${e===1?`y`:`ies`}.`);return}default:console.error(`Unknown stash action: ${t}`),console.error(`Actions: set, get, list, delete, clear`),process.exit(1)}}},{name:`lane`,description:`Manage verified lanes — isolated file copies for parallel exploration`,usage:`aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`,run:async e=>{let t=e.shift();if((!t||![`create`,`list`,`status`,`diff`,`merge`,`discard`].includes(t))&&(console.error(`Usage: aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`),process.exit(1)),t===`list`){let e=Se();if(e.length===0){console.log(`No active lanes.`);return}for(let t of e)console.log(`${t.name} (${t.sourceFiles.length} files, created ${t.createdAt})`);return}let n=e.shift();switch(n||(console.error(`Lane name is required for "${t}".`),process.exit(1)),t){case`create`:{let t=N(e,`--files`,``);t||(console.error(`Usage: aikit lane create <name> --files file1.ts,file2.ts`),process.exit(1));let r=ye(n,t.split(`,`).map(e=>e.trim()));console.log(`Lane "${r.name}" created with ${r.sourceFiles.length} files.`);break}case`status`:{let e=we(n);console.log(`Lane: ${e.name}`),console.log(`Modified: ${e.modified} | Added: ${e.added} | Deleted: ${e.deleted}`);for(let t of e.entries)console.log(` ${t.status.padEnd(10)} ${t.file}`);break}case`diff`:{let e=be(n);console.log(`Lane: ${e.name} — ${e.modified} modified, ${e.added} added, ${e.deleted} deleted`);for(let t of e.entries)t.diff&&(console.log(`\n--- ${t.file} (${t.status})`),console.log(t.diff));break}case`merge`:{let e=Ce(n);console.log(`Merged ${e.filesMerged} files from lane "${e.name}".`);for(let t of e.files)console.log(` ${t}`);break}case`discard`:{let e=xe(n);console.log(e?`Lane "${n}" discarded.`:`Lane "${n}" not found.`);break}}}},{name:`queue`,description:`Manage task queues for sequential agent operations`,usage:`aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`,run:async e=>{let t=e.shift();if((!t||![`create`,`push`,`next`,`done`,`fail`,`get`,`list`,`clear`,`delete`].includes(t))&&(console.error(`Usage: aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`),process.exit(1)),t===`list`){let e=Ee();if(e.length===0){console.log(`No queues.`);return}for(let t of e)console.log(`${t.name} pending:${t.pending} done:${t.done} failed:${t.failed} total:${t.total}`);return}let n=e.shift();switch(n||(console.error(`Queue name is required for "${t}".`),process.exit(1)),t){case`create`:{let e=w(n);console.log(`Queue "${e.name}" created.`);break}case`push`:{let t=Oe(n,e.join(` `)||`Untitled task`);console.log(`Pushed "${t.title}" (${t.id}) to queue "${n}".`);break}case`next`:{let e=De(n);console.log(e?`Next: ${e.title} (${e.id})`:`No pending items in queue "${n}".`);break}case`done`:{let t=e.shift();t||(console.error(`Usage: aikit queue done <name> <id>`),process.exit(1));let r=E(n,t);console.log(`Marked "${r.item.title}" as done.`);break}case`fail`:{let t=e.shift(),r=e.join(` `)||`Unknown error`;t||(console.error(`Usage: aikit queue fail <name> <id> [error message]`),process.exit(1));let i=D(n,t,r);console.log(`Marked "${i.title}" as failed: ${r}`);break}case`get`:{let e=O(n);if(!e){console.log(`Queue "${n}" not found.`);return}console.log(`Queue: ${e.name} (${e.items.length} items)`);for(let t of e.items){let e=t.error?` — ${t.error}`:``;console.log(` ${t.status.padEnd(12)} ${t.id} ${t.title}${e}`)}break}case`clear`:{let e=C(n);console.log(`Cleared ${e} completed/failed items from queue "${n}".`);break}case`delete`:{let e=T(n);console.log(e?`Queue "${n}" deleted.`:`Queue "${n}" not found.`);break}}}}],Q=[...kt,...Ot,...nt,...Dt,...At,...xt,...yt,...Nt,...bt,...Mt,...q];Q.push({name:`help`,description:`Show available commands`,run:async()=>{$()}});async function Pt(e){let t=[...e],n=t.shift();if(!n||n===`--help`||n===`-h`){$();return}if(n===`--version`||n===`-v`){let e=l(s(u(import.meta.url)),`..`,`..`,`..`,`package.json`),t=JSON.parse(a(e,`utf-8`));console.log(t.version);return}if(n&&new Set([`--user`,`--workspace`,`--guide`,`--smart`]).has(n)){let e=Q.find(e=>e.name===`init`);if(e){await e.run([n,...t]);return}}let r=Q.find(e=>e.name===n);r||(console.error(`Unknown command: ${n}`),$(),process.exit(1));try{await r.run(t)}finally{let e=Et();e&&await e.store.close()}}function $(){console.log(`@vpxa/aikit — Local-first AI developer toolkit
12
+ `)},s;t?(console.log(`Dropping existing index for full reindex...`),s=await r.reindexAll(a,o)):s=await r.index(a,o),console.log(`Done: ${s.filesProcessed} files, ${s.chunksCreated} chunks in ${(s.durationMs/1e3).toFixed(1)}s`),console.log(`Building FTS index...`),await n.createFtsIndex(),console.log(`Re-indexing curated entries...`);let c=await i.reindexAll();console.log(`Curated: ${c.indexed} entries restored`)}},{name:`serve`,description:`Start the MCP server (stdio or HTTP)`,usage:`aikit serve [--transport stdio|http] [--port N]`,run:async e=>{let t=l(Z(X),`packages`,`server`,`dist`,`index.js`),n=N(e,`--transport`,`stdio`),r=N(e,`--port`,`3210`),i=tt(t,[],{stdio:n===`stdio`?[`pipe`,`pipe`,`inherit`,`ipc`]:`inherit`,env:{...process.env,AIKIT_TRANSPORT:n,AIKIT_PORT:r}});n===`stdio`&&i.stdin&&i.stdout&&(process.stdin.pipe(i.stdin),i.stdout.pipe(process.stdout)),i.on(`exit`,e=>process.exit(e??0)),process.on(`SIGINT`,()=>i.kill(`SIGINT`)),process.on(`SIGTERM`,()=>i.kill(`SIGTERM`)),await new Promise(()=>{})}},{name:`init`,description:`Initialize AI Kit in the current directory`,usage:`aikit init [--workspace] [--smart] [--force] [--guide]`,run:async e=>{let t=e.includes(`--user`),n=e.includes(`--workspace`),r=e.includes(`--smart`),i=e.includes(`--guide`),a=e.includes(`--force`);if(t&&n&&(console.error(`Cannot use --user and --workspace together.`),process.exit(1)),i){let{guideProject:e}=await import(`./init-DlY4IHCF.js`);await e();return}if(r){let{initSmart:e}=await import(`./init-DlY4IHCF.js`);await e({force:a})}else if(t){let{initUser:e}=await import(`./user-DfEC00FY.js`);await e({force:a})}else if(n){let{initProject:e}=await import(`./init-DlY4IHCF.js`);await e({force:a})}else{let{initUser:e}=await import(`./user-DfEC00FY.js`);await e({force:a})}}},{name:`check`,description:`Run incremental typecheck and lint`,usage:`aikit check [--cwd <dir>] [--files f1,f2] [--skip-types] [--skip-lint] [--detail efficient|normal|full]`,run:async e=>{let t=N(e,`--cwd`,``).trim()||void 0,n=N(e,`--files`,``),r=N(e,`--detail`,`full`)||`full`,i=n.split(`,`).map(e=>e.trim()).filter(Boolean),a=!1;e.includes(`--skip-types`)&&(e.splice(e.indexOf(`--skip-types`),1),a=!0);let o=!1;e.includes(`--skip-lint`)&&(e.splice(e.indexOf(`--skip-lint`),1),o=!0);let s=await m({cwd:t,files:i.length>0?i:void 0,skipTypes:a,skipLint:o,detail:r});st(s),s.passed||(process.exitCode=1)}},{name:`batch`,description:`Execute built-in operations from JSON input`,usage:`aikit batch [--file path] [--concurrency N]`,run:async e=>{let t=N(e,`--file`,``).trim()||void 0,n=(()=>{let t=e.indexOf(`--concurrency`);if(t===-1||t+1>=e.length)return 0;let n=Number.parseInt(e.splice(t,2)[1],10);return Number.isNaN(n)?0:n})(),r=await rt(t);r.trim()||(console.error(`Usage: aikit batch [--file path] [--concurrency N]`),process.exit(1));let i=it(r),a=n>0?n:i.concurrency,o=i.operations.some(e=>e.type!==`check`)?await Y():null,s=await p(i.operations,async e=>vt(e,o),{concurrency:a});console.log(JSON.stringify(s,null,2)),s.some(e=>e.status===`error`)&&(process.exitCode=1)}},{name:`health`,description:`Run project health checks on the current directory`,usage:`aikit health [path]`,run:async e=>{let t=ve(e.shift());console.log(`Project Health: ${t.path}`),console.log(`─`.repeat(50));for(let e of t.checks){let t=e.status===`pass`?`+`:e.status===`warn`?`~`:`X`;console.log(` [${t}] ${e.name}: ${e.message}`)}console.log(`─`.repeat(50)),console.log(`Score: ${t.score}% — ${t.summary}`)}},{name:`audit`,description:`Run a unified project audit (structure, deps, patterns, health, dead symbols, check)`,usage:`aikit audit [path] [--checks structure,dependencies,patterns,health,dead_symbols,check,entry_points] [--detail efficient|normal|full]`,run:async e=>{let{store:t,embedder:n}=await Y(),r=N(e,`--detail`,`efficient`)||`efficient`,i=N(e,`--checks`,``),a=i?i.split(`,`).map(e=>e.trim()):void 0,o=await f(t,n,{path:e.shift()||`.`,checks:a,detail:r});if(o.ok){if(console.log(o.summary),o.next&&o.next.length>0){console.log(`
13
+ Suggested next steps:`);for(let e of o.next)console.log(` → ${e.tool}: ${e.reason}`)}}else console.error(o.error?.message??`Audit failed`),process.exitCode=1}},{name:`guide`,description:`Tool discovery — recommend AI Kit tools for a given goal`,usage:`aikit guide <goal> [--max N]`,run:async e=>{let t=e.indexOf(`--max`),n=5;t!==-1&&t+1<e.length&&(n=Number.parseInt(e.splice(t,2)[1],10)||5);let r=e.join(` `).trim();r||(console.error(`Usage: aikit guide <goal> [--max N]`),console.error(`Example: aikit guide "audit this project"`),process.exit(1));let i=_e(r,n);console.log(`Workflow: ${i.workflow}`),console.log(` ${i.description}\n`),console.log(`Recommended tools:`);for(let e of i.tools){let t=e.suggestedArgs?` ${JSON.stringify(e.suggestedArgs)}`:``;console.log(` ${e.order}. ${e.tool} — ${e.reason}${t}`)}i.alternativeWorkflows.length>0&&console.log(`\nAlternatives: ${i.alternativeWorkflows.join(`, `)}`)}},{name:`replay`,description:`Show recent tool invocation audit trail`,usage:`aikit replay [--last N] [--tool <name>] [--source mcp|cli]`,run:async e=>{let t=Me({last:Number.parseInt(e[e.indexOf(`--last`)+1],10)||20,tool:e.includes(`--tool`)?e[e.indexOf(`--tool`)+1]:void 0,source:e.includes(`--source`)?e[e.indexOf(`--source`)+1]:void 0});if(t.length===0){console.log(`No replay entries. Activity is logged when tools are invoked.`);return}console.log(`Replay Log (${t.length} entries)\n`);for(let e of t){let t=e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts,n=e.status===`ok`?`✓`:`✗`;console.log(`${t} ${n} ${e.tool} (${e.durationMs}ms) [${e.source}]`),console.log(` in: ${e.input}`),console.log(` out: ${e.output}`)}Ne().catch(()=>{})}},{name:`replay-clear`,description:`Clear the replay audit trail`,run:async()=>{je(),console.log(`Replay log cleared.`)}},{name:`dashboard`,description:`Launch web dashboard for knowledge graph visualization`,usage:`aikit dashboard [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=l(Z(X),`packages`,`server`,`dist`,`index.js`),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),u=`http://localhost:${r}/_dashboard/`,d=`http://localhost:${r}/health`,f=!1;for(let e=0;e<30;e+=1){try{if((await fetch(d)).ok){f=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(f||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Dashboard: ${u}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,u],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[u],{stdio:`ignore`,detached:!0}).unref()}let p=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,p),process.on(`SIGTERM`,p),await new Promise(e=>{c.on(`exit`,()=>e())})}},{name:`settings`,description:`Launch web UI to manage AI Kit configuration and environment variables`,usage:`aikit settings [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=l(Z(X),`packages`,`server`,`dist`,`index.js`),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),u=`http://localhost:${r}/settings/`,d=`http://localhost:${r}/health`,f=!1;for(let e=0;e<30;e+=1){try{if((await fetch(d)).ok){f=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(f||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Settings: ${u}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,u],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[u],{stdio:`ignore`,detached:!0}).unref()}let p=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,p),process.on(`SIGTERM`,p),await new Promise(e=>{c.on(`exit`,()=>e())})}}];function jt(e){let t=e;for(let e=0;e<10;e++){try{let e=c(t,`package.json`);if(r(e)&&JSON.parse(a(e,`utf8`)).name===`@vpxa/aikit`)return t}catch{}let e=s(t);if(e===t)break;t=e}return l(e,`..`,`..`,`..`)}const Mt=[{name:`upgrade`,description:`Upgrade AI Kit agents, prompts, and skills to the latest version (user-level and workspace-level)`,usage:`aikit upgrade`,run:async()=>{let{initUser:n}=await import(`./user-DfEC00FY.js`);await n({force:!0});let i=process.cwd(),o=r(l(i,`.github`,`.aikit-scaffold.json`)),c=r(l(i,`.github`,`agents`)),d=r(l(i,`.github`,`prompts`)),f=r(l(i,`.claude`,`commands`));if(o||c||d||f){let{initScaffoldOnly:e}=await import(`./init-DlY4IHCF.js`);await e({force:!0})}if(r(l(i,`.github`,`skills`))){let{smartCopySkills:n}=await import(`./scaffold-D664MT9M.js`),r=jt(s(u(import.meta.url))),o=JSON.parse(a(l(r,`package.json`),`utf-8`)).version;await n(i,r,[...e],o,!0);let{smartCopyFlows:c}=await import(`./scaffold-D664MT9M.js`);await c(i,r,[...t],o,!0)}}}],Nt=[{name:`workset`,description:`Manage saved file sets`,usage:`aikit workset <action> [name] [--files f1,f2] [--description desc]`,run:async e=>{let t=e.shift()?.trim(),n=I(N(e,`--files`,``)),r=N(e,`--description`,``).trim()||void 0,i=e.shift()?.trim();switch(t||(console.error(`Usage: aikit workset <action> [name] [--files f1,f2] [--description desc]`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)),t){case`save`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset save <name> --files f1,f2 [--description desc]`),process.exit(1));let e=Pe(i,n,{description:r});console.log(`Saved workset: ${e.name}`),B(e);return}case`get`:{i||(console.error(`Usage: aikit workset get <name>`),process.exit(1));let e=me(i);if(!e){console.log(`No workset found: ${i}`);return}B(e);return}case`list`:{let e=Te();if(e.length===0){console.log(`No worksets saved.`);return}console.log(`Worksets (${e.length})`),console.log(`─`.repeat(60));for(let t of e)B(t),console.log(``);return}case`delete`:{i||(console.error(`Usage: aikit workset delete <name>`),process.exit(1));let e=ce(i);console.log(e?`Deleted workset: ${i}`:`No workset found: ${i}`);return}case`add`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset add <name> --files f1,f2`),process.exit(1));let e=d(i,n);console.log(`Updated workset: ${e.name}`),B(e);return}case`remove`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset remove <name> --files f1,f2`),process.exit(1));let e=ke(i,n);if(!e){console.log(`No workset found: ${i}`);return}console.log(`Updated workset: ${e.name}`),B(e);return}default:console.error(`Unknown workset action: ${t}`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)}}},{name:`stash`,description:`Persist and retrieve named intermediate values`,usage:`aikit stash <set|get|list|delete|clear> [key] [value]`,run:async e=>{let t=e.shift()?.trim(),n=e.shift()?.trim();switch(t||(console.error(`Usage: aikit stash <set|get|list|delete|clear> [key] [value]`),process.exit(1)),t){case`set`:{n||(console.error(`Usage: aikit stash set <key> <value>`),process.exit(1));let t=e.join(` `),r=t.trim()?``:await F(),i=Be(n,gt(t||r));console.log(`Stored stash entry: ${i.key}`),console.log(` Type: ${i.type}`),console.log(` Stored: ${i.storedAt}`);return}case`get`:{n||(console.error(`Usage: aikit stash get <key>`),process.exit(1));let e=Re(n);if(!e){console.log(`No stash entry found: ${n}`);return}console.log(JSON.stringify(e,null,2));return}case`list`:{let e=ze();if(e.length===0){console.log(`No stash entries saved.`);return}console.log(`Stash entries (${e.length})`),console.log(`─`.repeat(60));for(let t of e)console.log(`${t.key} (${t.type})`),console.log(` Stored: ${t.storedAt}`);return}case`delete`:{n||(console.error(`Usage: aikit stash delete <key>`),process.exit(1));let e=Le(n);console.log(e?`Deleted stash entry: ${n}`:`No stash entry found: ${n}`);return}case`clear`:{let e=Ie();console.log(`Cleared ${e} stash entr${e===1?`y`:`ies`}.`);return}default:console.error(`Unknown stash action: ${t}`),console.error(`Actions: set, get, list, delete, clear`),process.exit(1)}}},{name:`lane`,description:`Manage verified lanes — isolated file copies for parallel exploration`,usage:`aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`,run:async e=>{let t=e.shift();if((!t||![`create`,`list`,`status`,`diff`,`merge`,`discard`].includes(t))&&(console.error(`Usage: aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`),process.exit(1)),t===`list`){let e=Se();if(e.length===0){console.log(`No active lanes.`);return}for(let t of e)console.log(`${t.name} (${t.sourceFiles.length} files, created ${t.createdAt})`);return}let n=e.shift();switch(n||(console.error(`Lane name is required for "${t}".`),process.exit(1)),t){case`create`:{let t=N(e,`--files`,``);t||(console.error(`Usage: aikit lane create <name> --files file1.ts,file2.ts`),process.exit(1));let r=ye(n,t.split(`,`).map(e=>e.trim()));console.log(`Lane "${r.name}" created with ${r.sourceFiles.length} files.`);break}case`status`:{let e=we(n);console.log(`Lane: ${e.name}`),console.log(`Modified: ${e.modified} | Added: ${e.added} | Deleted: ${e.deleted}`);for(let t of e.entries)console.log(` ${t.status.padEnd(10)} ${t.file}`);break}case`diff`:{let e=be(n);console.log(`Lane: ${e.name} — ${e.modified} modified, ${e.added} added, ${e.deleted} deleted`);for(let t of e.entries)t.diff&&(console.log(`\n--- ${t.file} (${t.status})`),console.log(t.diff));break}case`merge`:{let e=Ce(n);console.log(`Merged ${e.filesMerged} files from lane "${e.name}".`);for(let t of e.files)console.log(` ${t}`);break}case`discard`:{let e=xe(n);console.log(e?`Lane "${n}" discarded.`:`Lane "${n}" not found.`);break}}}},{name:`queue`,description:`Manage task queues for sequential agent operations`,usage:`aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`,run:async e=>{let t=e.shift();if((!t||![`create`,`push`,`next`,`done`,`fail`,`get`,`list`,`clear`,`delete`].includes(t))&&(console.error(`Usage: aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`),process.exit(1)),t===`list`){let e=Ee();if(e.length===0){console.log(`No queues.`);return}for(let t of e)console.log(`${t.name} pending:${t.pending} done:${t.done} failed:${t.failed} total:${t.total}`);return}let n=e.shift();switch(n||(console.error(`Queue name is required for "${t}".`),process.exit(1)),t){case`create`:{let e=w(n);console.log(`Queue "${e.name}" created.`);break}case`push`:{let t=Oe(n,e.join(` `)||`Untitled task`);console.log(`Pushed "${t.title}" (${t.id}) to queue "${n}".`);break}case`next`:{let e=De(n);console.log(e?`Next: ${e.title} (${e.id})`:`No pending items in queue "${n}".`);break}case`done`:{let t=e.shift();t||(console.error(`Usage: aikit queue done <name> <id>`),process.exit(1));let r=E(n,t);console.log(`Marked "${r.item.title}" as done.`);break}case`fail`:{let t=e.shift(),r=e.join(` `)||`Unknown error`;t||(console.error(`Usage: aikit queue fail <name> <id> [error message]`),process.exit(1));let i=D(n,t,r);console.log(`Marked "${i.title}" as failed: ${r}`);break}case`get`:{let e=O(n);if(!e){console.log(`Queue "${n}" not found.`);return}console.log(`Queue: ${e.name} (${e.items.length} items)`);for(let t of e.items){let e=t.error?` — ${t.error}`:``;console.log(` ${t.status.padEnd(12)} ${t.id} ${t.title}${e}`)}break}case`clear`:{let e=C(n);console.log(`Cleared ${e} completed/failed items from queue "${n}".`);break}case`delete`:{let e=T(n);console.log(e?`Queue "${n}" deleted.`:`Queue "${n}" not found.`);break}}}}],Q=[...kt,...Ot,...nt,...Dt,...At,...xt,...yt,...Nt,...bt,...Mt,...q];Q.push({name:`help`,description:`Show available commands`,run:async()=>{$()}});async function Pt(e){let t=[...e],n=t.shift();if(!n||n===`--help`||n===`-h`){$();return}if(n===`--version`||n===`-v`){let e=l(s(u(import.meta.url)),`..`,`..`,`..`,`package.json`),t=JSON.parse(a(e,`utf-8`));console.log(t.version);return}if(n&&new Set([`--user`,`--workspace`,`--guide`,`--smart`]).has(n)){let e=Q.find(e=>e.name===`init`);if(e){await e.run([n,...t]);return}}let r=Q.find(e=>e.name===n);r||(console.error(`Unknown command: ${n}`),$(),process.exit(1));try{await r.run(t)}finally{let e=Et();e&&await e.store.close()}}function $(){console.log(`@vpxa/aikit — Local-first AI developer toolkit
14
14
  `),console.log(`Usage: aikit <command> [options]
15
15
  `),console.log(`Commands:`);let e=Math.max(...Q.map(e=>e.name.length));for(let t of Q)console.log(` ${t.name.padEnd(e+2)}${t.description}`);console.log(``),console.log(`Options:`),console.log(` --help, -h Show this help`),console.log(` --version, -v Show version`)}export{Pt as run};
@@ -0,0 +1,7 @@
1
+ import{i as e,n as t,r as n,t as r}from"./constants-BHJ95m41.js";import{n as i,t as a}from"./templates-Dz2d2veK.js";import{guideFlows as o,guideScaffold as s,guideSkills as c,smartCopyClaudeCommands as l,smartCopyFlows as u,smartCopyScaffold as d,smartCopySkills as f}from"./scaffold-D664MT9M.js";import{appendFileSync as p,existsSync as m,mkdirSync as h,readFileSync as g,unlinkSync as _,writeFileSync as v}from"node:fs";import{basename as y,dirname as b,join as x,resolve as S}from"node:path";import{fileURLToPath as C}from"node:url";import{AIKIT_PATHS as w,isUserInstalled as T}from"../../core/dist/index.js";function E(e){return m(S(e,`.cursor`))?`cursor`:m(S(e,`.claude`))?`claude-code`:m(S(e,`.windsurf`))?`windsurf`:m(S(e,`.zed`))?`zed`:m(S(e,`.idea`))?`intellij`:`copilot`}function D(e){return{servers:{[e]:{...t}}}}function O(e){let{type:n,...r}=t;return{mcpServers:{[e]:r}}}function k(e){let{type:n,...r}=t;return{context_servers:{[e]:r}}}const A={scaffoldDir:`general`,writeMcpConfig(e,t){let n=S(e,`.vscode`),r=S(n,`mcp.json`);m(r)||(h(n,{recursive:!0}),v(r,`${JSON.stringify(D(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json`))},writeInstructions(e,t){let n=S(e,`.github`),r=S(n,`copilot-instructions.md`);h(n,{recursive:!0}),v(r,i(y(e),t),`utf-8`),console.log(` Updated .github/copilot-instructions.md`)},writeAgentsMd(e,t){v(S(e,`AGENTS.md`),a(y(e),t),`utf-8`),console.log(` Updated AGENTS.md`)}},j={scaffoldDir:`general`,writeMcpConfig(e,t){let n=S(e,`.mcp.json`);m(n)||(v(n,`${JSON.stringify(O(t),null,2)}\n`,`utf-8`),console.log(` Created .mcp.json`))},writeInstructions(e,t){let n=S(e,`CLAUDE.md`),r=y(e);v(n,`${i(r,t)}\n---\n\n${a(r,t)}`,`utf-8`),console.log(` Updated CLAUDE.md`)},writeAgentsMd(e,t){}},M={scaffoldDir:`general`,writeMcpConfig(e,t){let n=S(e,`.cursor`),r=S(n,`mcp.json`);m(r)||(h(n,{recursive:!0}),v(r,`${JSON.stringify(O(t),null,2)}\n`,`utf-8`),console.log(` Created .cursor/mcp.json`))},writeInstructions(e,t){let n=S(e,`.cursor`,`rules`),r=S(n,`aikit.mdc`);h(n,{recursive:!0});let o=y(e);v(r,`${i(o,t)}\n---\n\n${a(o,t)}`,`utf-8`),console.log(` Updated .cursor/rules/aikit.mdc`);let s=S(n,`kb.mdc`);m(s)&&s!==r&&(_(s),console.log(` Removed legacy .cursor/rules/kb.mdc`))},writeAgentsMd(e,t){}},N={scaffoldDir:`general`,writeMcpConfig(e,t){let n=S(e,`.vscode`),r=S(n,`mcp.json`);m(r)||(h(n,{recursive:!0}),v(r,`${JSON.stringify(D(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json (Windsurf-compatible)`))},writeInstructions(e,t){let n=S(e,`.windsurfrules`),r=y(e);v(n,`${i(r,t)}\n---\n\n${a(r,t)}`,`utf-8`),console.log(` Updated .windsurfrules`)},writeAgentsMd(e,t){}},P={scaffoldDir:`general`,writeMcpConfig(e,t){let n=S(e,`.zed`),r=S(n,`settings.json`);if(h(n,{recursive:!0}),!m(r))v(r,`${JSON.stringify(k(t),null,2)}\n`,`utf-8`),console.log(` Created .zed/settings.json`);else{let e;try{e=JSON.parse(g(r,`utf-8`))}catch{console.warn(` ⚠ .zed/settings.json contains invalid JSON — skipping MCP config merge`);return}e.context_servers?.[t]||(e.context_servers={...e.context_servers,...k(t).context_servers},v(r,`${JSON.stringify(e,null,2)}\n`,`utf-8`),console.log(` Updated .zed/settings.json with context_servers`))}},writeInstructions(e,t){let n=S(e,`.rules`),r=y(e);v(n,`${i(r,t)}\n---\n\n${a(r,t)}`,`utf-8`),console.log(` Updated .rules`)},writeAgentsMd(e,t){}},F={scaffoldDir:`general`,writeMcpConfig(e,t){let n=S(e,`.idea`),r=S(n,`mcp.json`);h(n,{recursive:!0}),m(r)||(v(r,`${JSON.stringify(O(t),null,2)}\n`,`utf-8`),console.log(` Created .idea/mcp.json`))},writeInstructions(e,t){let n=S(e,`.aiassistant`,`rules`),r=S(n,`aikit.md`);h(n,{recursive:!0});let o=y(e);v(r,`${i(o,t)}\n---\n\n${a(o,t)}`,`utf-8`),console.log(` Updated .aiassistant/rules/aikit.md`)},writeAgentsMd(e,t){}};function I(e){switch(e){case`copilot`:return A;case`claude-code`:return j;case`cursor`:return M;case`windsurf`:return N;case`zed`:return P;case`intellij`:return F}}const L={serverName:n,sources:[{path:`.`,excludePatterns:[`**/node_modules/**`,`**/dist/**`,`**/build/**`,`**/.git/**`,`**/${w.data}/**`,`**/coverage/**`,`**/*.min.js`,`**/package-lock.json`,`**/pnpm-lock.yaml`]}],indexing:{chunkSize:1500,chunkOverlap:200,minChunkSize:100},embedding:{model:`mixedbread-ai/mxbai-embed-large-v1`,dimensions:1024},store:{backend:`lancedb`,path:`${w.data}/lance`},curated:{path:w.aiCurated}};function R(e,t){let n=S(e,`aikit.config.json`);return m(n)&&!t?(console.log(`aikit.config.json already exists. Use --force to overwrite.`),!1):(v(n,`${JSON.stringify(L,null,2)}\n`,`utf-8`),console.log(` Created aikit.config.json`),!0)}function z(e){let t=S(e,`.gitignore`),n=[{dir:`${w.data}/`,label:`AI Kit vector store`},{dir:`${w.state}/`,label:`AI Kit session state`},{dir:`${w.restorePoints}/`,label:`Restore points (codemod/rename undo snapshots)`},{dir:`${w.brainstorm}/`,label:`Brainstorming sessions`},{dir:`${w.handoffs}/`,label:`Handoff documents`}];if(m(t)){let e=g(t,`utf-8`),r=n.filter(t=>!e.includes(t.dir));r.length>0&&(p(t,`\n${r.map(e=>`# ${e.label}\n${e.dir}`).join(`
2
+ `)}\n`,`utf-8`),console.log(` Added ${r.map(e=>e.dir).join(`, `)} to .gitignore`))}else v(t,`${n.map(e=>`# ${e.label}\n${e.dir}`).join(`
3
+ `)}\n`,`utf-8`),console.log(` Created .gitignore with AI Kit entries`)}function B(){return L.serverName}const V=[`decisions`,`patterns`,`conventions`,`troubleshooting`];function H(e){let t=S(e,`.ai`,`curated`);m(t)||(h(t,{recursive:!0}),console.log(` Created .ai/curated/`));for(let e of V){let n=S(t,e);m(n)||h(n,{recursive:!0})}console.log(` Created .ai/curated/{${V.join(`,`)}}/`)}function U(e){let t=e;for(let e=0;e<10;e++){try{let e=x(t,`package.json`);if(m(e)&&JSON.parse(g(e,`utf8`)).name===`@vpxa/aikit`)return t}catch{}let e=b(t);if(e===t)break;t=e}return S(e,`..`,`..`,`..`)}async function W(t){let n=process.cwd();if(!R(n,t.force))return;z(n);let i=B(),a=I(E(n));a.writeMcpConfig(n,i),a.writeInstructions(n,i),a.writeAgentsMd(n,i);let o=U(b(C(import.meta.url))),s=JSON.parse(g(S(o,`package.json`),`utf-8`)).version;await f(n,o,[...e],s,t.force),await u(n,o,[...r],s,t.force),await d(n,o,`copilot`,s,t.force),await l(n,o,s,t.force),H(n),console.log(`
4
+ AI Kit initialized! Next steps:`),console.log(` aikit reindex Index your codebase`),console.log(` aikit search Search indexed content`),console.log(` aikit serve Start MCP server for IDE integration`),T()&&console.log(`
5
+ Note: User-level AI Kit is also installed. This workspace uses its own local data store.`)}async function G(e){T()?await K(e):await W(e)}async function K(e){let t=process.cwd(),n=B(),i=I(E(t));i.writeInstructions(t,n),i.writeAgentsMd(t,n);let a=U(b(C(import.meta.url))),o=JSON.parse(g(S(a,`package.json`),`utf-8`)).version;await d(t,a,`copilot`,o,e.force),await l(t,a,o,e.force),await u(t,a,[...r],o,e.force),H(t),z(t),console.log(`
6
+ Workspace scaffolded for user-level AI Kit! Files added:`),console.log(` Instruction files (AGENTS.md, copilot-instructions.md, etc.)`),console.log(` .ai/curated/ directories`),console.log(` .github/agents/ & .github/prompts/`),console.log(`
7
+ The user-level AI Kit server will auto-index this workspace when opened in your IDE.`)}async function q(){let t=process.cwd(),n=I(E(t)),i=U(b(C(import.meta.url))),a=[...await c(t,i,[...e]),...await o(t,i,[...r]),...await s(t,i,n.scaffoldDir)],l={summary:{total:a.length,new:a.filter(e=>e.status===`new`).length,outdated:a.filter(e=>e.status===`outdated`).length,current:a.filter(e=>e.status===`current`).length},files:a};console.log(JSON.stringify(l,null,2))}export{q as guideProject,W as initProject,K as initScaffoldOnly,G as initSmart};