Spaces:
Sleeping
Sleeping
abrez β commited on
Commit Β·
de90a71
1
Parent(s): a5d1c1b
docs: add prerequisites, downloads guide, engines field, and .env.example
Browse files- .env.example +32 -0
- README.md +52 -19
- docs/wiki/03-developer-guide-and-testing.md +47 -38
- package.json +6 -1
.env.example
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==============================================================================
|
| 2 |
+
# Knowiki Environment Configuration
|
| 3 |
+
# ==============================================================================
|
| 4 |
+
# Copy this file to .env and configure for local development:
|
| 5 |
+
# cp .env.example .env (Linux/macOS) or Copy-Item .env.example .env (Windows)
|
| 6 |
+
|
| 7 |
+
# ------------------------------------------------------------------------------
|
| 8 |
+
# API Service Configuration (@knowiki/api)
|
| 9 |
+
# ------------------------------------------------------------------------------
|
| 10 |
+
PORT=3000
|
| 11 |
+
NODE_ENV=development
|
| 12 |
+
|
| 13 |
+
# GitHub Personal Access Token (Optional, but strongly recommended)
|
| 14 |
+
# Unauthenticated requests are limited by GitHub to 60 req/hr.
|
| 15 |
+
# Providing a PAT increases rate limits to 5,000 req/hr.
|
| 16 |
+
# Generate one at: https://github.com/settings/tokens (classic token with `repo` or `public_repo` scope)
|
| 17 |
+
GITHUB_TOKEN=
|
| 18 |
+
|
| 19 |
+
# In-memory Git Tree cache TTL in milliseconds (default: 60000 = 60s)
|
| 20 |
+
CACHE_TTL_MS=60000
|
| 21 |
+
|
| 22 |
+
# ------------------------------------------------------------------------------
|
| 23 |
+
# MCP Server Configuration (@knowiki/mcp)
|
| 24 |
+
# ------------------------------------------------------------------------------
|
| 25 |
+
MCP_PORT=3002
|
| 26 |
+
KNOWIKI_API_URL=http://localhost:3000
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------------------------
|
| 29 |
+
# CLI Configuration (@knowiki/cli)
|
| 30 |
+
# ------------------------------------------------------------------------------
|
| 31 |
+
# Set to custom API URL if overriding the default
|
| 32 |
+
# KNOWIKI_API_URL=http://localhost:3000
|
README.md
CHANGED
|
@@ -40,38 +40,71 @@ Comprehensive documentation is available in the [`docs/wiki/`](./docs/wiki/) dir
|
|
| 40 |
|
| 41 |
---
|
| 42 |
|
| 43 |
-
## π
|
| 44 |
|
| 45 |
-
### Prerequisites
|
| 46 |
-
- Node.js >= 20.0.0
|
| 47 |
-
- pnpm >= 9.0.0
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
### Running Services
|
| 57 |
```bash
|
| 58 |
-
# Start Knowiki API in development mode (
|
| 59 |
pnpm dev:api
|
| 60 |
|
| 61 |
-
# Start Knowiki MCP in development mode (
|
| 62 |
pnpm dev:mcp
|
| 63 |
|
| 64 |
-
#
|
| 65 |
pnpm dev:cli -- --help
|
| 66 |
|
| 67 |
-
# Run automated tests across all 3 packages
|
| 68 |
pnpm test
|
| 69 |
|
| 70 |
-
# Run TypeScript type check across all
|
| 71 |
pnpm typecheck
|
| 72 |
-
|
| 73 |
-
# Build all packages for production
|
| 74 |
-
pnpm build
|
| 75 |
```
|
| 76 |
|
| 77 |
---
|
|
|
|
| 40 |
|
| 41 |
---
|
| 42 |
|
| 43 |
+
## π Getting Started
|
| 44 |
|
| 45 |
+
### π Prerequisites & Downloads
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
Before installing Knowiki, ensure you have the following downloaded and installed on your machine:
|
| 48 |
+
|
| 49 |
+
| Software | Required Version | Download / Installation | Verify Command |
|
| 50 |
+
| :--- | :--- | :--- | :--- |
|
| 51 |
+
| **Node.js** | `>= 20.0.0` (LTS recommended) | [Download Node.js](https://nodejs.org/) | `node -v` |
|
| 52 |
+
| **pnpm** | `>= 9.0.0` | `npm install -g pnpm`<br>*(or `corepack enable && corepack prepare pnpm@latest --activate`)* | `pnpm -v` |
|
| 53 |
+
| **Git** | `>= 2.30.0` | [Download Git](https://git-scm.com/downloads) | `git --version` |
|
| 54 |
+
| **GitHub Token** *(Optional)* | Classic / Fine-grained PAT | [Generate Token](https://github.com/settings/tokens)<br>*(increases API limit from 60 to 5,000 req/hr)* | β |
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
### π¦ Installation & Setup
|
| 59 |
+
|
| 60 |
+
1. **Clone the repository:**
|
| 61 |
+
```bash
|
| 62 |
+
git clone https://github.com/abrez-rizvi/knowiki.git
|
| 63 |
+
cd knowiki
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
2. **Install monorepo dependencies:**
|
| 67 |
+
```bash
|
| 68 |
+
pnpm install
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
3. **Configure environment variables:**
|
| 72 |
+
```bash
|
| 73 |
+
# Copy the sample environment file
|
| 74 |
+
cp .env.example .env # On Windows: copy .env.example .env
|
| 75 |
+
```
|
| 76 |
+
*(Optional)* Open `.env` and add your `GITHUB_TOKEN` to unlock 5,000 req/hr rate limits.
|
| 77 |
+
|
| 78 |
+
4. **Build all packages:**
|
| 79 |
+
```bash
|
| 80 |
+
pnpm build
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
5. **(Optional) Install the Knowiki CLI globally:**
|
| 84 |
+
```bash
|
| 85 |
+
# Link the CLI binary so 'knowiki' command is available anywhere
|
| 86 |
+
pnpm --filter @knowiki/cli link --global
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
### π οΈ Running Services & Verification
|
| 92 |
|
|
|
|
| 93 |
```bash
|
| 94 |
+
# Start Knowiki API in development mode (http://localhost:3000)
|
| 95 |
pnpm dev:api
|
| 96 |
|
| 97 |
+
# Start Knowiki MCP Server in development mode (http://localhost:3002)
|
| 98 |
pnpm dev:mcp
|
| 99 |
|
| 100 |
+
# Test the Knowiki CLI locally
|
| 101 |
pnpm dev:cli -- --help
|
| 102 |
|
| 103 |
+
# Run all 76 automated tests across all 3 packages
|
| 104 |
pnpm test
|
| 105 |
|
| 106 |
+
# Run TypeScript type check across all packages
|
| 107 |
pnpm typecheck
|
|
|
|
|
|
|
|
|
|
| 108 |
```
|
| 109 |
|
| 110 |
---
|
docs/wiki/03-developer-guide-and-testing.md
CHANGED
|
@@ -4,71 +4,80 @@ This guide outlines how to configure, run, test, and verify the Knowiki codebase
|
|
| 4 |
|
| 5 |
---
|
| 6 |
|
| 7 |
-
## 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
```text
|
| 10 |
Knowiki-V1/
|
| 11 |
βββ packages/
|
| 12 |
β βββ api/ # Knowiki API Source Layer (@knowiki/api)
|
| 13 |
-
β β βββ src/
|
| 14 |
-
β β
|
| 15 |
-
β β
|
| 16 |
-
β
|
| 17 |
-
β β
|
| 18 |
-
β β
|
| 19 |
-
β β
|
| 20 |
-
β
|
| 21 |
-
β
|
| 22 |
-
β
|
| 23 |
-
β
|
| 24 |
-
β βββ mcp/ # Knowiki MCP Adapter (Upcoming)
|
| 25 |
-
β βββ cli/ # Knowiki CLI Plane (Upcoming)
|
| 26 |
βββ docs/
|
| 27 |
-
β βββ wiki/ # Complete Project Wiki Documentation
|
|
|
|
| 28 |
βββ package.json # Monorepo root manifest
|
| 29 |
βββ pnpm-workspace.yaml # pnpm workspace definition
|
| 30 |
```
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
-
##
|
| 35 |
-
|
| 36 |
-
All operations can be run from the root repository directory:
|
| 37 |
|
| 38 |
```bash
|
| 39 |
-
# Install
|
| 40 |
pnpm install
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
# Run
|
| 46 |
pnpm test
|
| 47 |
|
| 48 |
-
#
|
| 49 |
pnpm typecheck
|
| 50 |
-
|
| 51 |
-
# Build all packages for production
|
| 52 |
-
pnpm build
|
| 53 |
```
|
| 54 |
|
| 55 |
---
|
| 56 |
|
| 57 |
-
##
|
| 58 |
|
| 59 |
-
Automated testing is configured using **Vitest**
|
| 60 |
|
| 61 |
-
| Test Suite
|
| 62 |
| :--- | :--- | :--- |
|
| 63 |
-
| **
|
| 64 |
-
| **
|
| 65 |
-
| **
|
| 66 |
-
| **API Route Integration** | `api-routes.test.ts` | `GET /health`, `GET /repos/:owner/:repo`, `GET /repos/:owner/:repo/files`, `GET /repos/:owner/:repo/file/*`, and `/search`. |
|
| 67 |
-
|
| 68 |
-
To run the tests:
|
| 69 |
-
```bash
|
| 70 |
-
pnpm --filter @knowiki/api test
|
| 71 |
-
```
|
| 72 |
|
| 73 |
---
|
| 74 |
|
|
|
|
| 4 |
|
| 5 |
---
|
| 6 |
|
| 7 |
+
## 1. Prerequisites & Required Downloads
|
| 8 |
+
|
| 9 |
+
Before developing or running Knowiki locally, ensure the following tools are installed:
|
| 10 |
+
|
| 11 |
+
| Software | Required Version | Official Download / Install | Version Check |
|
| 12 |
+
| :--- | :--- | :--- | :--- |
|
| 13 |
+
| **Node.js** | `>= 20.0.0` (LTS recommended) | [nodejs.org](https://nodejs.org/) | `node -v` |
|
| 14 |
+
| **pnpm** | `>= 9.0.0` | `npm install -g pnpm`<br>*(or `corepack enable && corepack prepare pnpm@latest --activate`)* | `pnpm -v` |
|
| 15 |
+
| **Git** | `>= 2.30.0` | [git-scm.com](https://git-scm.com/downloads) | `git --version` |
|
| 16 |
+
| **GitHub Token** *(Optional)* | Classic / Fine-grained PAT | [GitHub Tokens](https://github.com/settings/tokens)<br>*(increases API limit from 60 to 5,000 req/hr)* | β |
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## 2. Monorepo Structure
|
| 21 |
|
| 22 |
```text
|
| 23 |
Knowiki-V1/
|
| 24 |
βββ packages/
|
| 25 |
β βββ api/ # Knowiki API Source Layer (@knowiki/api)
|
| 26 |
+
β β βββ src/ # Hono app, Git tree resolver, cache, routes
|
| 27 |
+
β β βββ test/ # API integration & unit tests
|
| 28 |
+
β β βββ package.json
|
| 29 |
+
β βββ mcp/ # Knowiki MCP Adapter (@knowiki/mcp)
|
| 30 |
+
β β βββ src/ # Streamable HTTP (2025-03-26) & SSE (2024-11-05)
|
| 31 |
+
β β βββ test/ # MCP protocol integration tests
|
| 32 |
+
β β βββ package.json
|
| 33 |
+
β βββ cli/ # Knowiki CLI Control Plane (@knowiki/cli)
|
| 34 |
+
β βββ src/ # Meta-skill bootstrap, cache, diff, push/propose
|
| 35 |
+
β βββ test/ # CLI command & cache tests
|
| 36 |
+
β βββ package.json
|
|
|
|
|
|
|
| 37 |
βββ docs/
|
| 38 |
+
β βββ wiki/ # Complete 6-Part Project Wiki Documentation
|
| 39 |
+
βββ .env.example # Sample environment configuration template
|
| 40 |
βββ package.json # Monorepo root manifest
|
| 41 |
βββ pnpm-workspace.yaml # pnpm workspace definition
|
| 42 |
```
|
| 43 |
|
| 44 |
---
|
| 45 |
|
| 46 |
+
## 3. Setup & Workspace Commands
|
|
|
|
|
|
|
| 47 |
|
| 48 |
```bash
|
| 49 |
+
# 1. Install dependencies across all packages
|
| 50 |
pnpm install
|
| 51 |
|
| 52 |
+
# 2. Configure environment variables
|
| 53 |
+
cp .env.example .env # Windows: copy .env.example .env
|
| 54 |
+
|
| 55 |
+
# 3. Build all TypeScript packages
|
| 56 |
+
pnpm build
|
| 57 |
+
|
| 58 |
+
# 4. Start services in development mode
|
| 59 |
+
pnpm dev:api # Start API on port 3000
|
| 60 |
+
pnpm dev:mcp # Start MCP server on port 3002
|
| 61 |
+
pnpm dev:cli -- --help # Run CLI locally
|
| 62 |
|
| 63 |
+
# 5. Run test suite across all 3 packages (76 tests)
|
| 64 |
pnpm test
|
| 65 |
|
| 66 |
+
# 6. Typecheck all packages
|
| 67 |
pnpm typecheck
|
|
|
|
|
|
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
---
|
| 71 |
|
| 72 |
+
## 4. Automated Test Suites
|
| 73 |
|
| 74 |
+
Automated testing is configured using **Vitest** across all packages (76 total tests):
|
| 75 |
|
| 76 |
+
| Package | Test Suite Files | What is Tested |
|
| 77 |
| :--- | :--- | :--- |
|
| 78 |
+
| **`@knowiki/api`** | `mime-and-filter.test.ts`<br>`tree-cache.test.ts`<br>`resolver-service.test.ts`<br>`api-routes.test.ts` | Resolves extensions, exclusions, in-memory TTL caching, Git tree ingestion, and HTTP endpoints (`/health`, `/repos`, `/files`, `/file/*`, `/search`). |
|
| 79 |
+
| **`@knowiki/mcp`** | `mcp-server-factory.test.ts`<br>`repo-context.test.ts`<br>`mcp-routes.test.ts`<br>`mcp-integration-e2e.test.ts` | Streamable HTTP & SSE transport endpoints, MCP resources (`knowiki://repo/...`), and tools (`list_files`, `read_file`, `search_files`). |
|
| 80 |
+
| **`@knowiki/cli`** | `project-config.test.ts`<br>`cache-and-dirty-state.test.ts`<br>`meta-skill-service.test.ts`<br>`materialize-service.test.ts`<br>`auth-service.test.ts`<br>`github-writer-service.test.ts`<br>`cli-commands.test.ts` | Pure filesystem cache (`.knowiki/`), config validation, dirty diff tracking, meta-skill generation for Antigravity/Cursor/Claude, and push/propose commands. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
---
|
| 83 |
|
package.json
CHANGED
|
@@ -10,7 +10,12 @@
|
|
| 10 |
"build": "pnpm --recursive run build",
|
| 11 |
"test": "pnpm --recursive run test",
|
| 12 |
"typecheck": "pnpm --recursive run typecheck",
|
| 13 |
-
"clean": "pnpm --recursive run clean"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
},
|
| 15 |
"devDependencies": {
|
| 16 |
"typescript": "^5.7.3"
|
|
|
|
| 10 |
"build": "pnpm --recursive run build",
|
| 11 |
"test": "pnpm --recursive run test",
|
| 12 |
"typecheck": "pnpm --recursive run typecheck",
|
| 13 |
+
"clean": "pnpm --recursive run clean",
|
| 14 |
+
"setup": "pnpm install && pnpm build"
|
| 15 |
+
},
|
| 16 |
+
"engines": {
|
| 17 |
+
"node": ">=20.0.0",
|
| 18 |
+
"pnpm": ">=9.0.0"
|
| 19 |
},
|
| 20 |
"devDependencies": {
|
| 21 |
"typescript": "^5.7.3"
|