codifier 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +543 -0
  2. package/commands/codify.md +7 -0
  3. package/commands/onboard.md +7 -0
  4. package/commands/push-memory.md +7 -0
  5. package/commands/recall.md +41 -0
  6. package/commands/remember.md +7 -0
  7. package/commands/research.md +7 -0
  8. package/dist/cli/add.d.ts +5 -0
  9. package/dist/cli/add.d.ts.map +1 -0
  10. package/dist/cli/add.js +25 -0
  11. package/dist/cli/add.js.map +1 -0
  12. package/dist/cli/bin/codifier.d.ts +7 -0
  13. package/dist/cli/bin/codifier.d.ts.map +1 -0
  14. package/dist/cli/bin/codifier.js +47 -0
  15. package/dist/cli/bin/codifier.js.map +1 -0
  16. package/dist/cli/detect.d.ts +15 -0
  17. package/dist/cli/detect.d.ts.map +1 -0
  18. package/dist/cli/detect.js +69 -0
  19. package/dist/cli/detect.js.map +1 -0
  20. package/dist/cli/doctor.d.ts +6 -0
  21. package/dist/cli/doctor.d.ts.map +1 -0
  22. package/dist/cli/doctor.js +71 -0
  23. package/dist/cli/doctor.js.map +1 -0
  24. package/dist/cli/init.d.ts +7 -0
  25. package/dist/cli/init.d.ts.map +1 -0
  26. package/dist/cli/init.js +144 -0
  27. package/dist/cli/init.js.map +1 -0
  28. package/dist/cli/update.d.ts +5 -0
  29. package/dist/cli/update.d.ts.map +1 -0
  30. package/dist/cli/update.js +38 -0
  31. package/dist/cli/update.js.map +1 -0
  32. package/dist/index.js +87 -0
  33. package/package.json +40 -0
  34. package/skills/brownfield-onboard/SKILL.md +142 -0
  35. package/skills/capture-session/SKILL.md +111 -0
  36. package/skills/initialize-project/SKILL.md +185 -0
  37. package/skills/initialize-project/templates/evals-prompt.md +39 -0
  38. package/skills/initialize-project/templates/requirements-prompt.md +44 -0
  39. package/skills/initialize-project/templates/roadmap-prompt.md +44 -0
  40. package/skills/initialize-project/templates/rules-prompt.md +34 -0
  41. package/skills/push-memory/SKILL.md +131 -0
  42. package/skills/research-analyze/SKILL.md +149 -0
  43. package/skills/research-analyze/templates/query-generation-prompt.md +61 -0
  44. package/skills/research-analyze/templates/synthesis-prompt.md +67 -0
  45. package/skills/shared/codifier-tools.md +187 -0
package/README.md ADDED
@@ -0,0 +1,543 @@
1
+ # CodifierMcp
2
+
3
+ **Institutional Memory for AI-Driven Development — Across Every Org Role**
4
+
5
+ CodifierMcp is a remote MCP (Model Context Protocol) server that gives AI assistants shared, persistent organizational knowledge. It captures learnings, decisions, and research findings from any team member — and surfaces them to any other member — creating a feedback loop that makes the organization smarter over time.
6
+
7
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
8
+ [![TypeScript](https://img.shields.io/badge/typescript-5.5.3-blue)](https://www.typescriptlang.org/)
9
+ [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-1.21.1-purple)](https://modelcontextprotocol.io/)
10
+
11
+ ---
12
+
13
+ ## Table of Contents
14
+
15
+ - [Overview](#overview)
16
+ - [Key Capabilities](#key-capabilities)
17
+ - [Architecture](#architecture)
18
+ - [Use Cases](#use-cases)
19
+ - [Prerequisites](#prerequisites)
20
+ - [Installation](#installation)
21
+ - [Configuration](#configuration)
22
+ - [Environment Variables](#environment-variables)
23
+ - [MCP Client Configuration](#mcp-client-configuration)
24
+ - [MCP Tools](#mcp-tools)
25
+ - [Skills](#skills)
26
+ - [Developer Skills](#developer-skills)
27
+ - [Researcher Skills](#researcher-skills)
28
+ - [Remote Server (HTTP Mode)](#remote-server-http-mode)
29
+ - [Development](#development)
30
+ - [Architecture Details](#architecture-details)
31
+ - [Roadmap](#roadmap)
32
+
33
+ ---
34
+
35
+ ## Overview
36
+
37
+ CodifierMcp bridges the gap between AI assistants and your organization's institutional knowledge. Instead of starting from scratch in every session, AI assistants can:
38
+
39
+ 1. **Fetch Context**: Retrieve relevant rules, guidelines, decisions, and research findings from the shared knowledge base
40
+ 2. **Update Memory**: Save new insights, patterns, and learnings discovered during development or research
41
+ 3. **Follow Skills**: Walk through guided, conversational workflows that produce structured artifacts (rules, roadmaps, research reports)
42
+ 4. **Integrate with Data Sources**: Pull in repo code via RepoMix and query data warehouses via Athena
43
+
44
+ This creates a virtuous cycle where knowledge from a developer's session informs a researcher's analysis, and vice versa.
45
+
46
+ ### Key Capabilities
47
+
48
+ 1. **Org-scoped knowledge persistence** — Learnings from any person, any role, any project persist in a shared, searchable KB. A developer's discovery about a legacy API informs a researcher's analysis six months later.
49
+
50
+ 2. **Authenticated connectors to proprietary data** — RepoMix for private code repositories; AWS Athena for data warehouses. Future: SharePoint, Confluence, Google Drive.
51
+
52
+ 3. **Local-first session memory** — Capture learnings, gotchas, conventions, and insights during any session. Review and edit locally in `docs/MEMORY.md`, then sync to the shared KB on demand. Every role produces learnings; memory capture is the foundational capability.
53
+
54
+ 4. **Guided friction reduction via Skills** — Role-specific conversational workflows. Developers get project initialization with rules and roadmaps. Researchers get data discovery and synthesis. The LLM reads the Skill and guides the conversation — no choppy step-by-step protocol.
55
+
56
+ 5. **Multi-surface access** — IDE via MCP (Cursor, Claude Code, Claude Desktop). CLI installer (`npx codifier init`). Future: Teams bot.
57
+
58
+ ### Architecture
59
+
60
+ ```
61
+ ┌──────────────────────────────────────────────────────┐
62
+ │ MCP Clients │
63
+ │ (Claude Desktop, Cursor, Claude Code) │
64
+ │ │
65
+ │ Skills + docs/MEMORY.md ← npx codifier init │
66
+ │ Slash Commands (.claude/commands/ or .cursor/rules/)│
67
+ └──────┬──────────────────────────┬────────────────────┘
68
+ │ stdio (local) │ SSE/HTTP (remote)
69
+ ↓ ↓
70
+ ┌─────────────────────────────────────────┐
71
+ │ CodifierMcp Server │
72
+ │ ├── Transport: stdio | SSE │
73
+ │ ├── Auth: Bearer token middleware │
74
+ │ └── MCP Tools (5) │
75
+ │ fetch_context / update_memory │
76
+ │ manage_projects / pack_repo │
77
+ │ query_data │
78
+ └──────┬──────────────────────────────────┘
79
+
80
+ ┌────┴────────────────────────────────┐
81
+ │ Supabase (PostgreSQL + pgvector) │
82
+ │ projects / repositories / memories │
83
+ │ api_keys │
84
+ └─────────────────────────────────────┘
85
+
86
+ Direct Integrations:
87
+ ├── RepoMix (npm programmatic API)
88
+ └── AWS Athena MCP (sidecar subprocess)
89
+ ```
90
+
91
+ **Skills are client-side.** Each Skill is a markdown instruction file the LLM reads locally. The LLM drives the conversation and calls MCP tools only for data operations. There is no server-side session state.
92
+
93
+ ### Use Cases
94
+
95
+ - **Project Initialization**: Follow the Initialize Project Skill to generate Rules.md, Evals.md, Requirements.md, and Roadmap.md from a description, SOW, or existing codebase
96
+ - **Brownfield Onboarding**: Pack an existing repo with RepoMix and generate an architectural summary
97
+ - **Research & Analysis**: Define a research objective, discover Athena schema, execute queries, synthesize findings
98
+ - **Cross-Role Knowledge Flow**: A researcher's findings (stored as `research_finding`) are retrieved by a developer via `fetch_context` when initializing a related project
99
+ - **Onboarding AI Assistants**: New AI sessions automatically learn your team's conventions and decisions
100
+ - **Session Memory Capture**: Capture learnings from any session — gotchas, conventions, insights — into `docs/MEMORY.md` via `/remember`, then sync to the shared KB via `/push-memory` for cross-team access
101
+
102
+ ---
103
+
104
+ ## Prerequisites
105
+
106
+ ### Remote Install (Recommended)
107
+
108
+ No local setup required. You need:
109
+
110
+ 1. **API auth token** — obtain from your Codifier deployment admin
111
+ 2. **MCP-compatible AI client** — Claude Desktop, Cursor, or Claude Code CLI
112
+
113
+ **Install Skills and MCP config in one command:**
114
+ ```bash
115
+ npx codifier init
116
+ ```
117
+
118
+ This scaffolds Skills into `.codifier/skills/`, writes slash commands to the correct client location, prompts for your server URL and API key, writes `.codifier/config.json` and the client-specific MCP config, and verifies connectivity.
119
+
120
+ ### Local / Self-Hosted Prerequisites
121
+
122
+ 1. **Node.js 18+** — `node --version`
123
+ 2. **Supabase project** — free tier at [supabase.com](https://supabase.com/); requires Project URL and Service Role Key
124
+ 3. **(Optional) AWS credentials** — for Research & Analyze Skill using Athena
125
+ 4. **(Optional) GitHub/GitLab token** — for private repo access via RepoMix
126
+
127
+ ---
128
+
129
+ ## Installation
130
+
131
+ ### Remote Install (Recommended)
132
+
133
+ ```bash
134
+ # Scaffold Skills and MCP config into your project
135
+ npx codifier init
136
+ ```
137
+
138
+ The CLI prompts for your Codifier server URL (default: `https://codifier-mcp.fly.dev`) and API key, then:
139
+ - Copies all Skills to `.codifier/skills/`
140
+ - Creates `docs/MEMORY.md` for session memory capture
141
+ - Writes slash commands to `.claude/commands/` (Claude Code), `.cursor/rules/` (Cursor), or `.codifier/commands/` (generic)
142
+ - Writes `.mcp.json` (Claude Code) or equivalent client config
143
+ - Verifies MCP connectivity via `GET /health`
144
+
145
+ Alternatively, configure the MCP connection manually:
146
+
147
+ ```bash
148
+ # Claude Code CLI
149
+ claude mcp add --transport http codifier https://codifier-mcp.fly.dev/mcp \
150
+ --header "Authorization: Bearer <your-token>"
151
+ ```
152
+
153
+ ### Local / Self-Hosted Install
154
+
155
+ ```bash
156
+ # 1. Clone
157
+ git clone https://github.com/yourusername/codifierMcp.git
158
+ cd codifierMcp
159
+
160
+ # 2. Install dependencies
161
+ npm install
162
+
163
+ # 3. Build
164
+ npm run build
165
+
166
+ # 4. Configure
167
+ cp .env.example .env
168
+ # Edit .env with your values
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Configuration
174
+
175
+ ### Environment Variables
176
+
177
+ ```bash
178
+ # Data Store (supabase is default; confluence is legacy)
179
+ DATA_STORE=supabase
180
+
181
+ # Supabase (required when DATA_STORE=supabase)
182
+ SUPABASE_URL=https://your-project.supabase.co
183
+ SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
184
+
185
+ # Transport mode
186
+ TRANSPORT_MODE=http # or stdio for local MCP clients
187
+
188
+ # HTTP auth (required when TRANSPORT_MODE=http)
189
+ HTTP_PORT=3000
190
+ API_AUTH_TOKEN=your-secure-random-token # openssl rand -base64 32
191
+
192
+ # Logging
193
+ LOG_LEVEL=info # debug | info | warn | error
194
+
195
+ # RepoMix — private repo access (optional)
196
+ GITHUB_TOKEN=ghp_xxxx
197
+ GITLAB_TOKEN=glpat-xxxx
198
+ BITBUCKET_TOKEN=xxxx
199
+
200
+ # AWS Athena — Research & Analyze Skill (optional)
201
+ AWS_REGION=us-east-1
202
+ AWS_ACCESS_KEY_ID=xxxx
203
+ AWS_SECRET_ACCESS_KEY=xxxx
204
+ ATHENA_S3_OUTPUT_LOCATION=s3://your-bucket/athena-results/
205
+ ATHENA_DATABASE=default
206
+ ATHENA_WORKGROUP=primary
207
+ ```
208
+
209
+ | Variable | Required | Description |
210
+ |----------|----------|-------------|
211
+ | `DATA_STORE` | No | `supabase` (default) or `confluence` |
212
+ | `SUPABASE_URL` | When `supabase` | Supabase project URL |
213
+ | `SUPABASE_SERVICE_ROLE_KEY` | When `supabase` | Service role key (not anon key) |
214
+ | `TRANSPORT_MODE` | No | `stdio` (default) or `http` |
215
+ | `HTTP_PORT` | No | Port for HTTP server (default: 3000) |
216
+ | `API_AUTH_TOKEN` | When `http` | Bearer token for authentication |
217
+ | `GITHUB_TOKEN` | For private repos | GitHub PAT with repo read access |
218
+ | `AWS_*` / `ATHENA_*` | For Research & Analyze | AWS credentials and Athena config |
219
+ | `ATHENA_DATABASE` | No | Athena database/catalog name (default: `"default"`); overridable per `query_data` call |
220
+
221
+ ### MCP Client Configuration
222
+
223
+ #### Claude Code (CLI)
224
+
225
+ ```bash
226
+ # Remote (recommended — or use npx codifier init)
227
+ claude mcp add --transport http codifier https://codifier-mcp.fly.dev/mcp \
228
+ --header "Authorization: Bearer <your-token>"
229
+
230
+ # Local
231
+ claude mcp add --transport http codifier http://localhost:3000/mcp \
232
+ --header "Authorization: Bearer <your-token>"
233
+ ```
234
+
235
+ #### Claude Desktop
236
+
237
+ Claude Desktop requires the `mcp-remote` proxy to connect to SSE servers:
238
+
239
+ ```json
240
+ {
241
+ "mcpServers": {
242
+ "codifier": {
243
+ "command": "npx",
244
+ "args": [
245
+ "-y",
246
+ "mcp-remote",
247
+ "https://codifier-mcp.fly.dev/mcp",
248
+ "--header",
249
+ "Authorization:Bearer <your-token>"
250
+ ]
251
+ }
252
+ }
253
+ }
254
+ ```
255
+
256
+ #### Cursor / Other MCP Clients
257
+
258
+ Configure as a StreamableHTTP server at `https://codifier-mcp.fly.dev/mcp` with `Authorization: Bearer <token>` header.
259
+
260
+ ---
261
+
262
+ ## MCP Tools
263
+
264
+ Codifier exposes 5 tools via the MCP protocol:
265
+
266
+ | Tool | Description |
267
+ |------|-------------|
268
+ | `fetch_context` | Retrieve memories from the KB filtered by `project_id`, `memory_type` (rule, document, api_contract, learning, research_finding), and/or `tags` |
269
+ | `update_memory` | Create or update a memory within the active project scope |
270
+ | `manage_projects` | Create, list, or switch the active project; all subsequent calls are scoped to it |
271
+ | `pack_repo` | Condense a local or remote repository via RepoMix and store it as a versioned snapshot in the `repositories` table |
272
+ | `query_data` | Execute operations against Athena: `list-tables` (schema discovery), `describe-tables` (column metadata), `execute-query` (SELECT only). Accepts optional `database` parameter to override the `ATHENA_DATABASE` env var per call. |
273
+
274
+ ### Memory Types
275
+
276
+ | Type | Description |
277
+ |------|-------------|
278
+ | `rule` | Project conventions, security patterns, coding standards |
279
+ | `document` | Technical specs, ADRs, runbooks, best practices |
280
+ | `api_contract` | Endpoint specifications, schemas, auth requirements |
281
+ | `learning` | Insights captured during AI-assisted development |
282
+ | `research_finding` | Data analysis results from Research & Analyze sessions |
283
+
284
+ ---
285
+
286
+ ## Skills
287
+
288
+ Skills are client-side, model-agnostic Agent workflows — markdown instruction files that the LLM reads locally. The LLM drives the conversation and calls MCP tools only for data operations. There is no server-side session state or protocol round-trips between steps.
289
+
290
+ After running `npx codifier init`, Skills live in `.codifier/skills/` in your project. Slash commands in `.claude/commands/` (or the equivalent for your client) activate each Skill.
291
+
292
+ `skills/shared/codifier-tools.md` is a reference document covering all 5 MCP tools, their parameters, and usage patterns. Every Skill references it.
293
+
294
+ ### Memory Skills (All Roles)
295
+
296
+ Memory capture is Codifier's foundational capability — every use case produces learnings worth persisting, whether or not it produces a structured artifact.
297
+
298
+ #### Capture Session (`/remember`)
299
+
300
+ Elicit and structure session learnings into `docs/MEMORY.md`. No MCP calls — local file only.
301
+
302
+ **Workflow:** elicit learnings from user → categorize (architecture, gotcha, convention, tooling, data, process) → dedup against existing entries → append to `docs/MEMORY.md`
303
+
304
+ #### Push Memory (`/push-memory`)
305
+
306
+ Sync unsynced local learnings to the shared KB with idempotent `[kb:<uuid>]` annotations.
307
+
308
+ **Workflow:** read `docs/MEMORY.md` → identify entries without `[kb:<uuid>]` prefix → preview and confirm → call `update_memory` per entry → write returned ID back as annotation
309
+
310
+ #### Recall (`/recall`)
311
+
312
+ Surface local and shared team learnings. Local recall is instant (no MCP call); shared KB recall uses `fetch_context` filtered by current task context.
313
+
314
+ ### Developer Skills
315
+
316
+ #### Initialize Project (`/codify`)
317
+
318
+ For greenfield and brownfield projects. Produces four artifacts persisted to the shared KB.
319
+
320
+ **Workflow:** collect project name and description → optionally accept SOW → optionally provide repo URLs → pack repos via `pack_repo` → generate Rules.md → generate Evals.md → generate Requirements.md → generate Roadmap.md → persist all artifacts via `update_memory`
321
+
322
+ **Context-aware generation:**
323
+
324
+ | Scenario | Context used | Generator behavior |
325
+ |----------|-------------|-------------------|
326
+ | Greenfield + SOW | description + SOW | Rules from SOW constraints and standards |
327
+ | Greenfield, no SOW | description only | Minimal scaffolding rules |
328
+ | Brownfield + SOW | description + SOW + repo snapshot | Target-state rules; SOW takes precedence over existing patterns |
329
+ | Brownfield, no SOW | description + repo snapshot | Rules extracted from existing codebase patterns |
330
+
331
+ #### Brownfield Onboard (`/onboard`)
332
+
333
+ Pack an existing repo and generate an architectural summary with minimal ceremony.
334
+
335
+ **Workflow:** collect repo URLs → call `pack_repo` for each → store versioned snapshots → generate architectural summary → persist learnings via `update_memory`
336
+
337
+ ### Researcher Skills
338
+
339
+ #### Research & Analyze (`/research`)
340
+
341
+ Connect to Athena, explore data, execute queries, synthesize findings.
342
+
343
+ **Workflow:** define research objective → provide context → discover Athena schema via `query_data list-tables` → select relevant tables → describe schemas via `query_data describe-tables` → generate SQL queries (user reviews before execution) → execute approved queries via `query_data execute-query` → synthesize findings → generate ResearchFindings.md → persist as `research_finding` memories via `update_memory`
344
+
345
+ ---
346
+
347
+ ## Remote Server (HTTP Mode)
348
+
349
+ ### Quick Start
350
+
351
+ ```bash
352
+ # Generate auth token
353
+ export API_AUTH_TOKEN=$(openssl rand -base64 32)
354
+
355
+ # Start in HTTP mode
356
+ TRANSPORT_MODE=http \
357
+ HTTP_PORT=3000 \
358
+ API_AUTH_TOKEN=$API_AUTH_TOKEN \
359
+ SUPABASE_URL=https://your-project.supabase.co \
360
+ SUPABASE_SERVICE_ROLE_KEY=your-key \
361
+ node dist/index.js
362
+ ```
363
+
364
+ ### Endpoints
365
+
366
+ | Endpoint | Methods | Auth | Description |
367
+ |----------|---------|------|-------------|
368
+ | `/health` | GET | No | Health check — returns `{"status":"ok"}` |
369
+ | `/.well-known/oauth-authorization-server` | GET | No | OAuth authorization server metadata (MCP SDK 1.7+ discovery) |
370
+ | `/.well-known/oauth-protected-resource` | GET | No | OAuth protected resource metadata |
371
+ | `/mcp` | POST | Yes | StreamableHTTP transport — stateless (MCP protocol 2025-03-26); GET/DELETE return 405 |
372
+ | `/sse` | GET | Yes | SSE transport for legacy clients |
373
+ | `/messages` | POST | Yes | SSE message endpoint |
374
+
375
+ ### Authentication
376
+
377
+ All endpoints except `/health`, `/.well-known/*`, and `OPTIONS` preflight requests require:
378
+ ```
379
+ Authorization: Bearer <API_AUTH_TOKEN>
380
+ ```
381
+
382
+ Requests without a valid token receive a `401` response with an OAuth-standard error body:
383
+ ```json
384
+ { "error": "unauthorized", "error_description": "..." }
385
+ ```
386
+
387
+ ---
388
+
389
+ ## Development
390
+
391
+ ### Project Structure
392
+
393
+ ```
394
+ codifierMcp/
395
+ ├── src/
396
+ │ ├── index.ts # Entry point (transport branching)
397
+ │ ├── config/
398
+ │ │ └── env.ts # Zod-validated configuration
399
+ │ ├── http/
400
+ │ │ ├── server.ts # Express server (StreamableHTTP + SSE)
401
+ │ │ └── auth-middleware.ts # Bearer token authentication
402
+ │ ├── datastore/
403
+ │ │ ├── interface.ts # IDataStore abstraction
404
+ │ │ ├── factory.ts # createDataStore() factory
405
+ │ │ ├── supabase-datastore.ts # Supabase implementation (default)
406
+ │ │ └── atlassian-datastore.ts # Confluence implementation (legacy)
407
+ │ ├── mcp/
408
+ │ │ ├── server.ts # Registers exactly 5 tools
409
+ │ │ ├── schemas.ts # Zod schemas for tool parameters
410
+ │ │ └── tools/ # 5 tool implementations
411
+ │ │ ├── fetch-context.ts
412
+ │ │ ├── update-memory.ts
413
+ │ │ ├── manage-projects.ts
414
+ │ │ ├── pack-repo.ts
415
+ │ │ └── query-data.ts
416
+ │ ├── integrations/
417
+ │ │ ├── repomix.ts # RepoMix programmatic API wrapper
418
+ │ │ └── athena.ts # Athena MCP sidecar client
419
+ │ ├── services/
420
+ │ │ ├── context-service.ts # Rule retrieval with relevance scoring
421
+ │ │ └── memory-service.ts # Memory enrichment and storage
422
+ │ └── utils/
423
+ │ ├── logger.ts # Logging (stderr only)
424
+ │ └── errors.ts # Custom error classes
425
+ ├── skills/
426
+ │ ├── shared/
427
+ │ │ └── codifier-tools.md # All 5 MCP tools reference
428
+ │ ├── capture-session/
429
+ │ │ └── SKILL.md
430
+ │ ├── push-memory/
431
+ │ │ └── SKILL.md
432
+ │ ├── initialize-project/
433
+ │ │ ├── SKILL.md
434
+ │ │ └── templates/
435
+ │ ├── brownfield-onboard/
436
+ │ │ └── SKILL.md
437
+ │ └── research-analyze/
438
+ │ ├── SKILL.md
439
+ │ └── templates/
440
+ ├── commands/
441
+ │ ├── codify.md # /codify slash command
442
+ │ ├── onboard.md # /onboard slash command
443
+ │ ├── research.md # /research slash command
444
+ │ ├── remember.md # /remember slash command
445
+ │ ├── push-memory.md # /push-memory slash command
446
+ │ └── recall.md # /recall slash command
447
+ ├── cli/
448
+ │ ├── bin/codifier.ts # CLI entry point
449
+ │ ├── detect.ts # LLM client detection
450
+ │ ├── init.ts # npx codifier init
451
+ │ ├── update.ts # npx codifier update
452
+ │ ├── add.ts # npx codifier add <skill>
453
+ │ └── doctor.ts # npx codifier doctor
454
+ ├── supabase/
455
+ │ └── migrations/
456
+ │ ├── 001_initial_schema.sql
457
+ │ └── 002_v2_schema.sql # Drops sessions/insights; v2.0 schema
458
+ ├── docs/
459
+ │ ├── rules.yaml # Project development rules
460
+ │ ├── evals.yaml # Rule evaluations
461
+ │ └── MEMORY.md # Session learnings (local-first, synced to KB via /push-memory)
462
+ ├── Dockerfile
463
+ ├── fly.toml
464
+ └── package.json
465
+ ```
466
+
467
+ ### Commands
468
+
469
+ ```bash
470
+ npm install # Install dependencies
471
+ npm run build # Compile TypeScript → dist/
472
+ npm run dev # Build + run (stdio mode)
473
+ npm run watch # Watch mode (rebuild on changes)
474
+ ```
475
+
476
+ ### Adding New Features
477
+
478
+ 1. Review `docs/rules.yaml` before writing code
479
+ 2. Follow the `IDataStore` interface for any storage changes
480
+ 3. Use custom error classes from `utils/errors.ts`
481
+ 4. Log to stderr only (never stdout) — MCP uses stdout for protocol
482
+ 5. Validate all inputs with Zod schemas in `src/mcp/schemas.ts`
483
+ 6. Use strict TypeScript; explicit types required
484
+
485
+ ---
486
+
487
+ ## Architecture Details
488
+
489
+ ### Data Schema
490
+
491
+ Migration `002_v2_schema.sql` (applied 2026-02-24) dropped the `sessions` and `insights` tables. The active schema has 4 tables:
492
+
493
+ | Table | Key Fields | Purpose |
494
+ |-------|-----------|---------|
495
+ | `projects` | id, name, org, metadata | Top-level container; all entities scoped to a project |
496
+ | `repositories` | id, project_id, url, snapshot, file_tree, version_label | Versioned repo snapshots from RepoMix |
497
+ | `memories` | id, project_id, memory_type, title, content, tags, confidence, embedding, source_role | All knowledge entities (rules, docs, learnings, findings) |
498
+ | `api_keys` | id, project_id, key_hash | API key → project mapping for RLS |
499
+
500
+ ### Retrieval Strategy
501
+
502
+ **MVP**: Exact-match filtering on `project_id`, `memory_type`, and `tags`. Embeddings are stored on write but vector similarity search is deferred to v2.1.
503
+
504
+ **v2.1**: Hybrid retrieval — exact-match filters + vector ranking via pgvector.
505
+
506
+ ### Why Skills Instead of a Server-Side PlaybookRunner
507
+
508
+ The original v2.0 design used a server-side `PlaybookRunner` state machine with a `sessions` table, `run_playbook`, and `advance_step` tools. This was replaced in February 2026 for three reasons:
509
+
510
+ 1. **Eliminating round-trips**: Each playbook step required an MCP call. Skills let the LLM manage workflow state in its context window — zero extra tool calls for step transitions.
511
+ 2. **Model agnosticism**: Skill markdown files work with any LLM client. The YAML playbook format tied generation to Codifier's server-side prompt assembly.
512
+ 3. **Simplified server**: 5 stateless tools are easier to reason about, test, and scale. The Fly.io deployment runs always-on (`min_machines_running = 1`, `auto_stop_machines = false`) — no cold-start delay for clients.
513
+
514
+ ---
515
+
516
+ ## Roadmap
517
+
518
+ ### v2.1
519
+
520
+ | Feature | Description |
521
+ |---------|-------------|
522
+ | **Semantic search** | Activate vector similarity on `memories.embedding`; hybrid retrieval |
523
+ | **SkillManager / Umbrella MCP** | Proxy pattern for Confluence, SharePoint, GitHub, Jira connectors |
524
+ | **Researcher data sources** | SharePoint + Google Drive as selectable sources in Research & Analyze |
525
+ | **Architect Skills** | Technology evaluation, system modeling, ADRs |
526
+ | **Strategist Skills** | Roadmap planning, competitive analysis |
527
+ | **Teams bot** | Read-only KB queries + Skill steps as Adaptive Cards |
528
+ | **SSO / Entra ID** | Replace API key auth with org SSO |
529
+ | **Memory relationships** | Graph edges between memories for relationship queries |
530
+
531
+ ---
532
+
533
+ ## Additional Resources
534
+
535
+ - **MCP Documentation**: [modelcontextprotocol.io](https://modelcontextprotocol.io/)
536
+ - **Supabase**: [supabase.com/docs](https://supabase.com/docs)
537
+ - **RepoMix**: [github.com/yamadashy/repomix](https://github.com/yamadashy/repomix)
538
+ - **AWS Athena MCP**: [github.com/ColeMurray/aws-athena-mcp](https://github.com/ColeMurray/aws-athena-mcp)
539
+ - **TypeScript Handbook**: [typescriptlang.org/docs](https://www.typescriptlang.org/docs/)
540
+
541
+ ---
542
+
543
+ **Built with Claude Code**
@@ -0,0 +1,7 @@
1
+ Read and follow the instructions in the initialize-project skill. Check these locations in order:
2
+ 1. skills/initialize-project/SKILL.md
3
+ 2. .codifier/skills/initialize-project/SKILL.md
4
+
5
+ Use the Codifier MCP tools as directed by the skill.
6
+
7
+ If the skill file is not found at either location, inform the user: "Codifier skills are not installed yet. Run `npx @codifier/cli init` in your terminal to install them, then try this command again."
@@ -0,0 +1,7 @@
1
+ Read and follow the instructions in the brownfield-onboard skill. Check these locations in order:
2
+ 1. skills/brownfield-onboard/SKILL.md
3
+ 2. .codifier/skills/brownfield-onboard/SKILL.md
4
+
5
+ Use the Codifier MCP tools as directed by the skill.
6
+
7
+ If the skill file is not found at either location, inform the user: "Codifier skills are not installed yet. Run `npx @codifier/cli init` in your terminal to install them, then try this command again."
@@ -0,0 +1,7 @@
1
+ Read and follow the instructions in the push-memory skill. Check these locations in order:
2
+ 1. skills/push-memory/SKILL.md
3
+ 2. .codifier/skills/push-memory/SKILL.md
4
+
5
+ Use the Codifier MCP tools as directed by the skill.
6
+
7
+ If the skill file is not found at either location, inform the user: "Codifier skills are not installed yet. Run `npx @codifier/cli init` in your terminal to install them, then try this command again."
@@ -0,0 +1,41 @@
1
+ # Recall — Surface Local and Shared Learnings
2
+
3
+ Follow these steps:
4
+
5
+ ## Step 1 — Read Local Memory
6
+
7
+ Attempt to read `docs/MEMORY.md`. Check this location first, then `.codifier/docs/MEMORY.md`.
8
+
9
+ If the file exists, summarize its contents grouped by category under the heading **"Your Local Learnings"**. Include all entries regardless of sync status — entries with `[kb:...]` prefixes are synced to the shared KB; those without are local-only. Make the sync status visible: show a note next to each category indicating how many entries are synced vs. local-only.
10
+
11
+ If the file does not exist, inform the user: "No local memory file found. Run `/remember` to capture session learnings, or `npx @codifier/cli init` to set up your project."
12
+
13
+ ## Step 2 — Offer Shared KB Recall
14
+
15
+ Ask the user: **"What are you working on right now?"**
16
+
17
+ Use their answer to call `fetch_context` with:
18
+
19
+ ```json
20
+ {
21
+ "project_id": "<from MEMORY.md header, or ask the user if not present>",
22
+ "memory_type": "learning",
23
+ "tags": ["session-context"],
24
+ "query": "<user's current task description>",
25
+ "limit": 10
26
+ }
27
+ ```
28
+
29
+ If no `project_id` is available from the file header, ask the user to provide it or call `manage_projects` with `operation: "list"` to help them identify it.
30
+
31
+ Present KB results under a separate heading **"Shared Team Learnings"** — distinct and clearly separated from the local section. Never merge or deduplicate local and KB results — they are different sources and must remain visually distinct.
32
+
33
+ If the user declines to answer the question or states they only want local results, skip the `fetch_context` call and omit the "Shared Team Learnings" section entirely.
34
+
35
+ ## Step 3 — Summary
36
+
37
+ Tell the user:
38
+
39
+ - How many local learnings were found in total (and how many are unsynced, i.e., missing a `[kb:...]` prefix)
40
+ - How many shared team learnings were retrieved from the KB (if the call was made)
41
+ - "Run /remember to capture new learnings, or /push-memory to sync local learnings to the shared KB"
@@ -0,0 +1,7 @@
1
+ Read and follow the instructions in the capture-session skill. Check these locations in order:
2
+ 1. skills/capture-session/SKILL.md
3
+ 2. .codifier/skills/capture-session/SKILL.md
4
+
5
+ Use the Codifier MCP tools as directed by the skill.
6
+
7
+ If the skill file is not found at either location, inform the user: "Codifier skills are not installed yet. Run `npx @codifier/cli init` in your terminal to install them, then try this command again."
@@ -0,0 +1,7 @@
1
+ Read and follow the instructions in the research-analyze skill. Check these locations in order:
2
+ 1. skills/research-analyze/SKILL.md
3
+ 2. .codifier/skills/research-analyze/SKILL.md
4
+
5
+ Use the Codifier MCP tools as directed by the skill.
6
+
7
+ If the skill file is not found at either location, inform the user: "Codifier skills are not installed yet. Run `npx @codifier/cli init` in your terminal to install them, then try this command again."
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `codifier add <skill>` — install a single skill by name.
3
+ */
4
+ export declare function runAdd(skillName: string): Promise<void>;
5
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../cli/add.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,wBAAsB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB7D"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `codifier add <skill>` — install a single skill by name.
3
+ */
4
+ import { cpSync, existsSync, mkdirSync } from 'fs';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import { detectEnvironment } from './detect.js';
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const PACKAGE_ROOT = join(__dirname, '..', '..');
10
+ const SKILLS_SOURCE = join(PACKAGE_ROOT, 'skills');
11
+ export async function runAdd(skillName) {
12
+ const cwd = process.cwd();
13
+ const env = detectEnvironment(cwd);
14
+ const skillSource = join(SKILLS_SOURCE, skillName);
15
+ if (!existsSync(skillSource)) {
16
+ console.error(`Error: Skill "${skillName}" not found.`);
17
+ console.error('Available skills: initialize-project, brownfield-onboard, research-analyze');
18
+ process.exit(1);
19
+ }
20
+ const skillDest = join(env.skillsDir, skillName);
21
+ mkdirSync(skillDest, { recursive: true });
22
+ cpSync(skillSource, skillDest, { recursive: true });
23
+ console.log(`✓ Skill "${skillName}" installed to ${skillDest}`);
24
+ }
25
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../cli/add.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,SAAiB;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAEnD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,iBAAiB,SAAS,cAAc,CAAC,CAAC;QACxD,OAAO,CAAC,KAAK,CAAC,4EAA4E,CAAC,CAAC;QAC5F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACjD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpD,OAAO,CAAC,GAAG,CAAC,YAAY,SAAS,kBAAkB,SAAS,EAAE,CAAC,CAAC;AAClE,CAAC"}