abrez β€Ž commited on
Commit
de90a71
Β·
1 Parent(s): a5d1c1b

docs: add prerequisites, downloads guide, engines field, and .env.example

Browse files
.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
- ## πŸš€ Quickstart
44
 
45
- ### Prerequisites
46
- - Node.js >= 20.0.0
47
- - pnpm >= 9.0.0
48
 
49
- ### Installation
50
- ```bash
51
- git clone https://github.com/your-org/knowiki.git
52
- cd knowiki
53
- pnpm install
54
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- ### Running Services
57
  ```bash
58
- # Start Knowiki API in development mode (port 3000 or $PORT)
59
  pnpm dev:api
60
 
61
- # Start Knowiki MCP in development mode (port 3002 or $MCP_PORT)
62
  pnpm dev:mcp
63
 
64
- # Run Knowiki CLI in development mode
65
  pnpm dev:cli -- --help
66
 
67
- # Run automated tests across all 3 packages (76 tests)
68
  pnpm test
69
 
70
- # Run TypeScript type check across all 3 packages
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. Monorepo Structure
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  ```text
10
  Knowiki-V1/
11
  β”œβ”€β”€ packages/
12
  β”‚ β”œβ”€β”€ api/ # Knowiki API Source Layer (@knowiki/api)
13
- β”‚ β”‚ β”œβ”€β”€ src/
14
- β”‚ β”‚ β”‚ β”œβ”€β”€ config.ts # Environment & runtime config
15
- β”‚ β”‚ β”‚ β”œβ”€β”€ app.ts # Hono app instance & route mounts
16
- β”‚ β”‚ β”‚ β”œβ”€β”€ index.ts # Node.js server launcher & graceful shutdown
17
- β”‚ β”‚ β”‚ β”œβ”€β”€ routes/ # Health, Repos, Files, Search routes
18
- β”‚ β”‚ β”‚ β”œβ”€β”€ services/ # GitHub service, Resolver, TreeCache, Search
19
- β”‚ β”‚ β”‚ β”œβ”€β”€ types/ # Exportable contract types
20
- β”‚ β”‚ β”‚ └── utils/ # MIME mapper, binary filter, visual logger
21
- β”‚ β”‚ β”œβ”€β”€ test/ # Vitest unit & integration test suites
22
- β”‚ β”‚ β”œβ”€β”€ package.json
23
- β”‚ β”‚ └── tsconfig.json
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
- ## 2. Common Workspace Commands
35
-
36
- All operations can be run from the root repository directory:
37
 
38
  ```bash
39
- # Install all dependencies across all packages
40
  pnpm install
41
 
42
- # Start the API in watch mode
43
- pnpm dev:api
 
 
 
 
 
 
 
 
44
 
45
- # Run the test suite across all packages
46
  pnpm test
47
 
48
- # Run TypeScript typechecks
49
  pnpm typecheck
50
-
51
- # Build all packages for production
52
- pnpm build
53
  ```
54
 
55
  ---
56
 
57
- ## 3. Automated Test Suite
58
 
59
- Automated testing is configured using **Vitest** in [`packages/api/test/`](file:///d:/Knowiki-V1/packages/api/test/):
60
 
61
- | Test Suite | File | What is Tested |
62
  | :--- | :--- | :--- |
63
- | **MIME & Filter** | `mime-and-filter.test.ts` | Resolves extensions (`.md`, `.ts`, `.json`, `LICENSE`, `Makefile`), verifies binary/lockfile exclusions. |
64
- | **Tree Cache** | `tree-cache.test.ts` | In-memory keying, TTL expiration, invalidation, and case-insensitivity. |
65
- | **Resolver Service** | `resolver-service.test.ts` | Git tree ingestion, prefix filtering, uppercase case-insensitive resolution, cache hit/miss semantics. |
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"