@synth-coder/memhub 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +45 -45
- package/.factory/commands/opsx-apply.md +150 -150
- package/.factory/commands/opsx-archive.md +155 -155
- package/.factory/commands/opsx-explore.md +171 -171
- package/.factory/commands/opsx-propose.md +104 -104
- package/.factory/skills/openspec-apply-change/SKILL.md +156 -156
- package/.factory/skills/openspec-archive-change/SKILL.md +114 -114
- package/.factory/skills/openspec-explore/SKILL.md +288 -288
- package/.factory/skills/openspec-propose/SKILL.md +110 -110
- package/.github/workflows/ci.yml +110 -110
- package/.github/workflows/release.yml +3 -0
- package/.iflow/commands/opsx-apply.md +152 -152
- package/.iflow/commands/opsx-archive.md +157 -157
- package/.iflow/commands/opsx-explore.md +173 -173
- package/.iflow/commands/opsx-propose.md +106 -106
- package/.iflow/skills/openspec-apply-change/SKILL.md +156 -156
- package/.iflow/skills/openspec-archive-change/SKILL.md +114 -114
- package/.iflow/skills/openspec-explore/SKILL.md +288 -288
- package/.iflow/skills/openspec-propose/SKILL.md +110 -110
- package/.prettierrc +11 -11
- package/AGENTS.md +167 -167
- package/README.md +17 -9
- package/README.zh-CN.md +246 -238
- package/dist/src/cli/agents/index.d.ts +0 -1
- package/dist/src/cli/agents/index.d.ts.map +1 -1
- package/dist/src/cli/agents/index.js +0 -3
- package/dist/src/cli/agents/index.js.map +1 -1
- package/dist/src/cli/index.js +0 -0
- package/dist/src/cli/init.d.ts.map +1 -1
- package/dist/src/cli/init.js +4 -24
- package/dist/src/cli/init.js.map +1 -1
- package/dist/src/cli/types.d.ts +2 -2
- package/dist/src/cli/types.d.ts.map +1 -1
- package/dist/src/cli/types.js +0 -11
- package/dist/src/cli/types.js.map +1 -1
- package/docs/user-guide.md +8 -6
- package/package.json +16 -16
- package/src/cli/agents/claude-code.ts +1 -1
- package/src/cli/agents/cline.ts +1 -1
- package/src/cli/agents/codex.ts +2 -2
- package/src/cli/agents/cursor.ts +1 -1
- package/src/cli/agents/factory-droid.ts +1 -1
- package/src/cli/agents/gemini-cli.ts +1 -1
- package/src/cli/agents/windsurf.ts +1 -1
- package/src/cli/init.ts +14 -14
- package/test/cli/init.test.ts +23 -1
- package/tsconfig.json +25 -25
- package/tsconfig.test.json +8 -8
- package/vitest.config.ts +29 -29
- package/dist/src/cli/agents/codex.d.ts +0 -5
- package/dist/src/cli/agents/codex.d.ts.map +0 -1
- package/dist/src/cli/agents/codex.js +0 -14
- package/dist/src/cli/agents/codex.js.map +0 -1
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: openspec-propose
|
|
3
|
-
description: Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.
|
|
4
|
-
license: MIT
|
|
5
|
-
compatibility: Requires openspec CLI.
|
|
6
|
-
metadata:
|
|
7
|
-
author: openspec
|
|
8
|
-
version: "1.0"
|
|
9
|
-
generatedBy: "1.2.0"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
Propose a new change - create the change and generate all artifacts in one step.
|
|
13
|
-
|
|
14
|
-
I'll create a change with artifacts:
|
|
15
|
-
- proposal.md (what & why)
|
|
16
|
-
- design.md (how)
|
|
17
|
-
- tasks.md (implementation steps)
|
|
18
|
-
|
|
19
|
-
When ready to implement, run /opsx:apply
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
|
|
24
|
-
|
|
25
|
-
**Steps**
|
|
26
|
-
|
|
27
|
-
1. **If no clear input provided, ask what they want to build**
|
|
28
|
-
|
|
29
|
-
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
30
|
-
> "What change do you want to work on? Describe what you want to build or fix."
|
|
31
|
-
|
|
32
|
-
From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
|
|
33
|
-
|
|
34
|
-
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
35
|
-
|
|
36
|
-
2. **Create the change directory**
|
|
37
|
-
```bash
|
|
38
|
-
openspec new change "<name>"
|
|
39
|
-
```
|
|
40
|
-
This creates a scaffolded change at `openspec/changes/<name>/` with `.openspec.yaml`.
|
|
41
|
-
|
|
42
|
-
3. **Get the artifact build order**
|
|
43
|
-
```bash
|
|
44
|
-
openspec status --change "<name>" --json
|
|
45
|
-
```
|
|
46
|
-
Parse the JSON to get:
|
|
47
|
-
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
48
|
-
- `artifacts`: list of all artifacts with their status and dependencies
|
|
49
|
-
|
|
50
|
-
4. **Create artifacts in sequence until apply-ready**
|
|
51
|
-
|
|
52
|
-
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
53
|
-
|
|
54
|
-
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
55
|
-
|
|
56
|
-
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
57
|
-
- Get instructions:
|
|
58
|
-
```bash
|
|
59
|
-
openspec instructions <artifact-id> --change "<name>" --json
|
|
60
|
-
```
|
|
61
|
-
- The instructions JSON includes:
|
|
62
|
-
- `context`: Project background (constraints for you - do NOT include in output)
|
|
63
|
-
- `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
|
|
64
|
-
- `template`: The structure to use for your output file
|
|
65
|
-
- `instruction`: Schema-specific guidance for this artifact type
|
|
66
|
-
- `outputPath`: Where to write the artifact
|
|
67
|
-
- `dependencies`: Completed artifacts to read for context
|
|
68
|
-
- Read any completed dependency files for context
|
|
69
|
-
- Create the artifact file using `template` as the structure
|
|
70
|
-
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
71
|
-
- Show brief progress: "Created <artifact-id>"
|
|
72
|
-
|
|
73
|
-
b. **Continue until all `applyRequires` artifacts are complete**
|
|
74
|
-
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
75
|
-
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
76
|
-
- Stop when all `applyRequires` artifacts are done
|
|
77
|
-
|
|
78
|
-
c. **If an artifact requires user input** (unclear context):
|
|
79
|
-
- Use **AskUserQuestion tool** to clarify
|
|
80
|
-
- Then continue with creation
|
|
81
|
-
|
|
82
|
-
5. **Show final status**
|
|
83
|
-
```bash
|
|
84
|
-
openspec status --change "<name>"
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
**Output**
|
|
88
|
-
|
|
89
|
-
After completing all artifacts, summarize:
|
|
90
|
-
- Change name and location
|
|
91
|
-
- List of artifacts created with brief descriptions
|
|
92
|
-
- What's ready: "All artifacts created! Ready for implementation."
|
|
93
|
-
- Prompt: "Run `/opsx:apply` or ask me to implement to start working on the tasks."
|
|
94
|
-
|
|
95
|
-
**Artifact Creation Guidelines**
|
|
96
|
-
|
|
97
|
-
- Follow the `instruction` field from `openspec instructions` for each artifact type
|
|
98
|
-
- The schema defines what each artifact should contain - follow it
|
|
99
|
-
- Read dependency artifacts for context before creating new ones
|
|
100
|
-
- Use `template` as the structure for your output file - fill in its sections
|
|
101
|
-
- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
|
|
102
|
-
- Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
|
|
103
|
-
- These guide what you write, but should never appear in the output
|
|
104
|
-
|
|
105
|
-
**Guardrails**
|
|
106
|
-
- Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`)
|
|
107
|
-
- Always read dependency artifacts before creating a new one
|
|
108
|
-
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
|
|
109
|
-
- If a change with that name already exists, ask if user wants to continue it or create a new one
|
|
110
|
-
- Verify each artifact file exists after writing before proceeding to next
|
|
1
|
+
---
|
|
2
|
+
name: openspec-propose
|
|
3
|
+
description: Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: Requires openspec CLI.
|
|
6
|
+
metadata:
|
|
7
|
+
author: openspec
|
|
8
|
+
version: "1.0"
|
|
9
|
+
generatedBy: "1.2.0"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Propose a new change - create the change and generate all artifacts in one step.
|
|
13
|
+
|
|
14
|
+
I'll create a change with artifacts:
|
|
15
|
+
- proposal.md (what & why)
|
|
16
|
+
- design.md (how)
|
|
17
|
+
- tasks.md (implementation steps)
|
|
18
|
+
|
|
19
|
+
When ready to implement, run /opsx:apply
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
|
|
24
|
+
|
|
25
|
+
**Steps**
|
|
26
|
+
|
|
27
|
+
1. **If no clear input provided, ask what they want to build**
|
|
28
|
+
|
|
29
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
30
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
31
|
+
|
|
32
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
|
|
33
|
+
|
|
34
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
35
|
+
|
|
36
|
+
2. **Create the change directory**
|
|
37
|
+
```bash
|
|
38
|
+
openspec new change "<name>"
|
|
39
|
+
```
|
|
40
|
+
This creates a scaffolded change at `openspec/changes/<name>/` with `.openspec.yaml`.
|
|
41
|
+
|
|
42
|
+
3. **Get the artifact build order**
|
|
43
|
+
```bash
|
|
44
|
+
openspec status --change "<name>" --json
|
|
45
|
+
```
|
|
46
|
+
Parse the JSON to get:
|
|
47
|
+
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
48
|
+
- `artifacts`: list of all artifacts with their status and dependencies
|
|
49
|
+
|
|
50
|
+
4. **Create artifacts in sequence until apply-ready**
|
|
51
|
+
|
|
52
|
+
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
53
|
+
|
|
54
|
+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
55
|
+
|
|
56
|
+
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
57
|
+
- Get instructions:
|
|
58
|
+
```bash
|
|
59
|
+
openspec instructions <artifact-id> --change "<name>" --json
|
|
60
|
+
```
|
|
61
|
+
- The instructions JSON includes:
|
|
62
|
+
- `context`: Project background (constraints for you - do NOT include in output)
|
|
63
|
+
- `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
|
|
64
|
+
- `template`: The structure to use for your output file
|
|
65
|
+
- `instruction`: Schema-specific guidance for this artifact type
|
|
66
|
+
- `outputPath`: Where to write the artifact
|
|
67
|
+
- `dependencies`: Completed artifacts to read for context
|
|
68
|
+
- Read any completed dependency files for context
|
|
69
|
+
- Create the artifact file using `template` as the structure
|
|
70
|
+
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
71
|
+
- Show brief progress: "Created <artifact-id>"
|
|
72
|
+
|
|
73
|
+
b. **Continue until all `applyRequires` artifacts are complete**
|
|
74
|
+
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
75
|
+
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
76
|
+
- Stop when all `applyRequires` artifacts are done
|
|
77
|
+
|
|
78
|
+
c. **If an artifact requires user input** (unclear context):
|
|
79
|
+
- Use **AskUserQuestion tool** to clarify
|
|
80
|
+
- Then continue with creation
|
|
81
|
+
|
|
82
|
+
5. **Show final status**
|
|
83
|
+
```bash
|
|
84
|
+
openspec status --change "<name>"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Output**
|
|
88
|
+
|
|
89
|
+
After completing all artifacts, summarize:
|
|
90
|
+
- Change name and location
|
|
91
|
+
- List of artifacts created with brief descriptions
|
|
92
|
+
- What's ready: "All artifacts created! Ready for implementation."
|
|
93
|
+
- Prompt: "Run `/opsx:apply` or ask me to implement to start working on the tasks."
|
|
94
|
+
|
|
95
|
+
**Artifact Creation Guidelines**
|
|
96
|
+
|
|
97
|
+
- Follow the `instruction` field from `openspec instructions` for each artifact type
|
|
98
|
+
- The schema defines what each artifact should contain - follow it
|
|
99
|
+
- Read dependency artifacts for context before creating new ones
|
|
100
|
+
- Use `template` as the structure for your output file - fill in its sections
|
|
101
|
+
- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
|
|
102
|
+
- Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
|
|
103
|
+
- These guide what you write, but should never appear in the output
|
|
104
|
+
|
|
105
|
+
**Guardrails**
|
|
106
|
+
- Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`)
|
|
107
|
+
- Always read dependency artifacts before creating a new one
|
|
108
|
+
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
|
|
109
|
+
- If a change with that name already exists, ask if user wants to continue it or create a new one
|
|
110
|
+
- Verify each artifact file exists after writing before proceeding to next
|
package/.prettierrc
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"semi": true,
|
|
3
|
-
"trailingComma": "es5",
|
|
4
|
-
"singleQuote": true,
|
|
5
|
-
"printWidth": 100,
|
|
6
|
-
"tabWidth": 2,
|
|
7
|
-
"useTabs": false,
|
|
8
|
-
"bracketSpacing": true,
|
|
9
|
-
"arrowParens": "avoid",
|
|
10
|
-
"endOfLine": "lf"
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"trailingComma": "es5",
|
|
4
|
+
"singleQuote": true,
|
|
5
|
+
"printWidth": 100,
|
|
6
|
+
"tabWidth": 2,
|
|
7
|
+
"useTabs": false,
|
|
8
|
+
"bracketSpacing": true,
|
|
9
|
+
"arrowParens": "avoid",
|
|
10
|
+
"endOfLine": "lf"
|
|
11
|
+
}
|
package/AGENTS.md
CHANGED
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
# AGENTS.md - MemHub Project Guide
|
|
2
|
-
|
|
3
|
-
## Project Overview
|
|
4
|
-
|
|
5
|
-
MemHub is a Git-friendly memory MCP server for coding agents. It stores decisions, preferences, and reusable knowledge as plain Markdown files with YAML front matter.
|
|
6
|
-
|
|
7
|
-
**Tech Stack**: TypeScript (ES2022), Node.js 18+, MCP SDK, Zod, LanceDB, Transformers.js
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Dev Environment
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npx pnpm install # Install dependencies
|
|
15
|
-
npx pnpm run build # Compile TypeScript
|
|
16
|
-
npx pnpm run quality # Quality gate (lint + typecheck + test + coverage)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
| Command | Description |
|
|
20
|
-
|---------|-------------|
|
|
21
|
-
| `npx pnpm run build` | Compile TypeScript |
|
|
22
|
-
| `npx pnpm run lint` | ESLint check |
|
|
23
|
-
| `npx pnpm run lint:fix` | Auto-fix lint issues |
|
|
24
|
-
| `npx pnpm run format` | Format code with Prettier |
|
|
25
|
-
| `npx pnpm run typecheck` | TypeScript type check |
|
|
26
|
-
| `npx pnpm run test` | Run Vitest tests |
|
|
27
|
-
| `npx pnpm run test:coverage` | Tests with coverage |
|
|
28
|
-
| `npx pnpm run quality` | Full quality gate |
|
|
29
|
-
| `npx pnpm vitest run -t "test name"` | Run specific test |
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Project Structure
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
src/
|
|
37
|
-
contracts/ # Type definitions, Zod schemas, MCP contracts
|
|
38
|
-
cli/ # CLI commands (init, etc.)
|
|
39
|
-
server/ # MCP stdio server entry point
|
|
40
|
-
services/ # Business logic (MemoryService, EmbeddingService)
|
|
41
|
-
storage/ # Storage layer (Markdown, VectorIndex)
|
|
42
|
-
utils/ # Shared utilities (slugify, etc.)
|
|
43
|
-
test/ # Vitest unit tests mirroring src/ structure
|
|
44
|
-
docs/ # Documentation
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## Coding Style
|
|
50
|
-
|
|
51
|
-
### TypeScript Conventions
|
|
52
|
-
- Use `readonly` for immutable fields in interfaces
|
|
53
|
-
- Use `type` for aliases, `interface` for object shapes
|
|
54
|
-
- Prefer `import type` for type-only imports
|
|
55
|
-
- Use ESM: `.js` extension in imports, `verbatimModuleSyntax`
|
|
56
|
-
- Explicit return types on exported functions
|
|
57
|
-
- Use Zod for runtime validation
|
|
58
|
-
|
|
59
|
-
### File Naming
|
|
60
|
-
- `kebab-case.ts` for all files
|
|
61
|
-
- Test files: `<module>.test.ts` or `<module>-edge.test.ts`
|
|
62
|
-
|
|
63
|
-
### Example Code Style
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
// Types with readonly fields
|
|
67
|
-
export interface Memory {
|
|
68
|
-
readonly id: UUID;
|
|
69
|
-
readonly tags: readonly string[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Service with explicit types
|
|
73
|
-
export class MemoryService {
|
|
74
|
-
constructor(private readonly config: MemoryServiceConfig) {}
|
|
75
|
-
|
|
76
|
-
async create(input: CreateMemoryInput): Promise<CreateResult> {
|
|
77
|
-
// implementation
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Zod schema for validation
|
|
82
|
-
export const MemorySchema = z.object({
|
|
83
|
-
id: z.string().uuid(),
|
|
84
|
-
tags: z.array(z.string()),
|
|
85
|
-
});
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## Workflows
|
|
91
|
-
|
|
92
|
-
### Add New MCP Tool
|
|
93
|
-
|
|
94
|
-
1. **Define types** → `src/contracts/types.ts`
|
|
95
|
-
2. **Define schema** → `src/contracts/schemas.ts`
|
|
96
|
-
3. **Register tool** → `src/contracts/mcp.ts`
|
|
97
|
-
4. **Implement logic** → `src/services/memory-service.ts`
|
|
98
|
-
5. **Add tests** → `test/services/memory-service.test.ts`
|
|
99
|
-
6. **Update docs** → `docs/mcp-tools.md`
|
|
100
|
-
7. **Run quality gate** → `npx pnpm run quality`
|
|
101
|
-
|
|
102
|
-
### Support New Agent
|
|
103
|
-
|
|
104
|
-
1. **Add agent type** → `src/cli/types.ts` (AgentType union)
|
|
105
|
-
2. **Create agent config** → `src/cli/agents/<agent-name>.ts`
|
|
106
|
-
3. **Register in init** → `src/cli/init.ts` (AGENT_CONFIGS map)
|
|
107
|
-
4. **Add tests** → `test/cli/init.test.ts`
|
|
108
|
-
5. **Update docs** → `docs/user-guide.md` (supported agents table)
|
|
109
|
-
6. **Update README** → `README.md` and `README.zh-CN.md`
|
|
110
|
-
7. **Run quality gate** → `npx pnpm run quality`
|
|
111
|
-
|
|
112
|
-
### Release New Version
|
|
113
|
-
|
|
114
|
-
1. **Update version** → `package.json`
|
|
115
|
-
2. **Update Roadmap** → `README.md` (mark released items)
|
|
116
|
-
3. **Run quality gate** → `npx pnpm run quality`
|
|
117
|
-
4. **Commit & tag** → `git commit && git tag v<x.y.z>`
|
|
118
|
-
5. **Publish** → `npm publish`
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## Documentation Sync
|
|
123
|
-
|
|
124
|
-
Documentation must stay in sync with code. **Update docs when changing:**
|
|
125
|
-
|
|
126
|
-
| Code Change | Update Doc |
|
|
127
|
-
|-------------|------------|
|
|
128
|
-
| MCP tool parameters/returns | `docs/mcp-tools.md` |
|
|
129
|
-
| CLI options/behavior | `docs/user-guide.md` |
|
|
130
|
-
| New agent support | `docs/user-guide.md`, `README.md` |
|
|
131
|
-
| Version number | `README.md` Roadmap |
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## Testing Guidelines
|
|
136
|
-
|
|
137
|
-
- **Coverage threshold**: >= 80%
|
|
138
|
-
- Tests mirror `src/` structure in `test/` directory
|
|
139
|
-
- Use Vitest: `describe`, `it`, `expect` pattern
|
|
140
|
-
- Edge cases go in `*-edge.test.ts` files
|
|
141
|
-
- Run `npx pnpm run quality` before committing
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
## Git Workflow
|
|
146
|
-
|
|
147
|
-
- Commit message: `type: description` (feat/fix/docs/chore/refactor/test)
|
|
148
|
-
- Always run quality gate before committing
|
|
149
|
-
- PR title: `[scope] Description`
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Dos and Don'ts
|
|
154
|
-
|
|
155
|
-
### Do
|
|
156
|
-
- Run `npx pnpm run quality` before committing
|
|
157
|
-
- Add tests for new code
|
|
158
|
-
- Use `import type` for type-only imports
|
|
159
|
-
- Keep functions small and focused
|
|
160
|
-
- Update types, schemas, and docs together
|
|
161
|
-
|
|
162
|
-
### Don't
|
|
163
|
-
- Skip the quality gate
|
|
164
|
-
- Use `any` without justification
|
|
165
|
-
- Mutate function parameters
|
|
166
|
-
- Add code without corresponding tests
|
|
167
|
-
- Commit directly to main (use branches for features)
|
|
1
|
+
# AGENTS.md - MemHub Project Guide
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
MemHub is a Git-friendly memory MCP server for coding agents. It stores decisions, preferences, and reusable knowledge as plain Markdown files with YAML front matter.
|
|
6
|
+
|
|
7
|
+
**Tech Stack**: TypeScript (ES2022), Node.js 18+, MCP SDK, Zod, LanceDB, Transformers.js
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Dev Environment
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx pnpm install # Install dependencies
|
|
15
|
+
npx pnpm run build # Compile TypeScript
|
|
16
|
+
npx pnpm run quality # Quality gate (lint + typecheck + test + coverage)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Command | Description |
|
|
20
|
+
|---------|-------------|
|
|
21
|
+
| `npx pnpm run build` | Compile TypeScript |
|
|
22
|
+
| `npx pnpm run lint` | ESLint check |
|
|
23
|
+
| `npx pnpm run lint:fix` | Auto-fix lint issues |
|
|
24
|
+
| `npx pnpm run format` | Format code with Prettier |
|
|
25
|
+
| `npx pnpm run typecheck` | TypeScript type check |
|
|
26
|
+
| `npx pnpm run test` | Run Vitest tests |
|
|
27
|
+
| `npx pnpm run test:coverage` | Tests with coverage |
|
|
28
|
+
| `npx pnpm run quality` | Full quality gate |
|
|
29
|
+
| `npx pnpm vitest run -t "test name"` | Run specific test |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
src/
|
|
37
|
+
contracts/ # Type definitions, Zod schemas, MCP contracts
|
|
38
|
+
cli/ # CLI commands (init, etc.)
|
|
39
|
+
server/ # MCP stdio server entry point
|
|
40
|
+
services/ # Business logic (MemoryService, EmbeddingService)
|
|
41
|
+
storage/ # Storage layer (Markdown, VectorIndex)
|
|
42
|
+
utils/ # Shared utilities (slugify, etc.)
|
|
43
|
+
test/ # Vitest unit tests mirroring src/ structure
|
|
44
|
+
docs/ # Documentation
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Coding Style
|
|
50
|
+
|
|
51
|
+
### TypeScript Conventions
|
|
52
|
+
- Use `readonly` for immutable fields in interfaces
|
|
53
|
+
- Use `type` for aliases, `interface` for object shapes
|
|
54
|
+
- Prefer `import type` for type-only imports
|
|
55
|
+
- Use ESM: `.js` extension in imports, `verbatimModuleSyntax`
|
|
56
|
+
- Explicit return types on exported functions
|
|
57
|
+
- Use Zod for runtime validation
|
|
58
|
+
|
|
59
|
+
### File Naming
|
|
60
|
+
- `kebab-case.ts` for all files
|
|
61
|
+
- Test files: `<module>.test.ts` or `<module>-edge.test.ts`
|
|
62
|
+
|
|
63
|
+
### Example Code Style
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// Types with readonly fields
|
|
67
|
+
export interface Memory {
|
|
68
|
+
readonly id: UUID;
|
|
69
|
+
readonly tags: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Service with explicit types
|
|
73
|
+
export class MemoryService {
|
|
74
|
+
constructor(private readonly config: MemoryServiceConfig) {}
|
|
75
|
+
|
|
76
|
+
async create(input: CreateMemoryInput): Promise<CreateResult> {
|
|
77
|
+
// implementation
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Zod schema for validation
|
|
82
|
+
export const MemorySchema = z.object({
|
|
83
|
+
id: z.string().uuid(),
|
|
84
|
+
tags: z.array(z.string()),
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Workflows
|
|
91
|
+
|
|
92
|
+
### Add New MCP Tool
|
|
93
|
+
|
|
94
|
+
1. **Define types** → `src/contracts/types.ts`
|
|
95
|
+
2. **Define schema** → `src/contracts/schemas.ts`
|
|
96
|
+
3. **Register tool** → `src/contracts/mcp.ts`
|
|
97
|
+
4. **Implement logic** → `src/services/memory-service.ts`
|
|
98
|
+
5. **Add tests** → `test/services/memory-service.test.ts`
|
|
99
|
+
6. **Update docs** → `docs/mcp-tools.md`
|
|
100
|
+
7. **Run quality gate** → `npx pnpm run quality`
|
|
101
|
+
|
|
102
|
+
### Support New Agent
|
|
103
|
+
|
|
104
|
+
1. **Add agent type** → `src/cli/types.ts` (AgentType union)
|
|
105
|
+
2. **Create agent config** → `src/cli/agents/<agent-name>.ts`
|
|
106
|
+
3. **Register in init** → `src/cli/init.ts` (AGENT_CONFIGS map)
|
|
107
|
+
4. **Add tests** → `test/cli/init.test.ts`
|
|
108
|
+
5. **Update docs** → `docs/user-guide.md` (supported agents table)
|
|
109
|
+
6. **Update README** → `README.md` and `README.zh-CN.md`
|
|
110
|
+
7. **Run quality gate** → `npx pnpm run quality`
|
|
111
|
+
|
|
112
|
+
### Release New Version
|
|
113
|
+
|
|
114
|
+
1. **Update version** → `package.json`
|
|
115
|
+
2. **Update Roadmap** → `README.md` (mark released items)
|
|
116
|
+
3. **Run quality gate** → `npx pnpm run quality`
|
|
117
|
+
4. **Commit & tag** → `git commit && git tag v<x.y.z>`
|
|
118
|
+
5. **Publish** → `npm publish`
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Documentation Sync
|
|
123
|
+
|
|
124
|
+
Documentation must stay in sync with code. **Update docs when changing:**
|
|
125
|
+
|
|
126
|
+
| Code Change | Update Doc |
|
|
127
|
+
|-------------|------------|
|
|
128
|
+
| MCP tool parameters/returns | `docs/mcp-tools.md` |
|
|
129
|
+
| CLI options/behavior | `docs/user-guide.md` |
|
|
130
|
+
| New agent support | `docs/user-guide.md`, `README.md` |
|
|
131
|
+
| Version number | `README.md` Roadmap |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Testing Guidelines
|
|
136
|
+
|
|
137
|
+
- **Coverage threshold**: >= 80%
|
|
138
|
+
- Tests mirror `src/` structure in `test/` directory
|
|
139
|
+
- Use Vitest: `describe`, `it`, `expect` pattern
|
|
140
|
+
- Edge cases go in `*-edge.test.ts` files
|
|
141
|
+
- Run `npx pnpm run quality` before committing
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Git Workflow
|
|
146
|
+
|
|
147
|
+
- Commit message: `type: description` (feat/fix/docs/chore/refactor/test)
|
|
148
|
+
- Always run quality gate before committing
|
|
149
|
+
- PR title: `[scope] Description`
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Dos and Don'ts
|
|
154
|
+
|
|
155
|
+
### Do
|
|
156
|
+
- Run `npx pnpm run quality` before committing
|
|
157
|
+
- Add tests for new code
|
|
158
|
+
- Use `import type` for type-only imports
|
|
159
|
+
- Keep functions small and focused
|
|
160
|
+
- Update types, schemas, and docs together
|
|
161
|
+
|
|
162
|
+
### Don't
|
|
163
|
+
- Skip the quality gate
|
|
164
|
+
- Use `any` without justification
|
|
165
|
+
- Mutate function parameters
|
|
166
|
+
- Add code without corresponding tests
|
|
167
|
+
- Commit directly to main (use branches for features)
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Git-friendly memory MCP server for coding agents.
|
|
|
11
11
|
Configure MemHub for your AI agent with a single command:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npx -y @synth-coder/memhub init
|
|
14
|
+
npx -y @synth-coder/memhub@latest init
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
This launches an interactive prompt to select your agent. MemHub will:
|
|
@@ -34,16 +34,16 @@ This launches an interactive prompt to select your agent. MemHub will:
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
# Interactive selection (global - default)
|
|
37
|
-
npx -y @synth-coder/memhub init
|
|
37
|
+
npx -y @synth-coder/memhub@latest init
|
|
38
38
|
|
|
39
39
|
# Skip interactive prompt
|
|
40
|
-
npx -y @synth-coder/memhub init -a claude-code
|
|
40
|
+
npx -y @synth-coder/memhub@latest init -a claude-code
|
|
41
41
|
|
|
42
42
|
# Configure for current project only (local)
|
|
43
|
-
npx -y @synth-coder/memhub init -a cursor -l
|
|
43
|
+
npx -y @synth-coder/memhub@latest init -a cursor -l
|
|
44
44
|
|
|
45
45
|
# Update existing configuration
|
|
46
|
-
npx -y @synth-coder/memhub init -a claude-code --force
|
|
46
|
+
npx -y @synth-coder/memhub@latest init -a claude-code --force
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
| Option | Description |
|
|
@@ -55,7 +55,7 @@ npx -y @synth-coder/memhub init -a claude-code --force
|
|
|
55
55
|
### Run as MCP Server
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
npx -y @synth-coder/memhub
|
|
58
|
+
npx -y @synth-coder/memhub@latest
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
> On Windows, do **not** append `memhub` after the package name.
|
|
@@ -69,7 +69,7 @@ If you prefer manual setup, add this to your MCP client config:
|
|
|
69
69
|
"mcpServers": {
|
|
70
70
|
"memhub": {
|
|
71
71
|
"command": "npx",
|
|
72
|
-
"args": ["-y", "@synth-coder/memhub"],
|
|
72
|
+
"args": ["-y", "@synth-coder/memhub@latest"],
|
|
73
73
|
"env": {
|
|
74
74
|
"MEMHUB_STORAGE_PATH": "/absolute/path/to/memories",
|
|
75
75
|
"MEMHUB_LOG_LEVEL": "info"
|
|
@@ -79,6 +79,14 @@ If you prefer manual setup, add this to your MCP client config:
|
|
|
79
79
|
}
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
For Codex (`~/.codex/config.toml`), use TOML key `mcp_servers`:
|
|
83
|
+
|
|
84
|
+
```toml
|
|
85
|
+
[mcp_servers.memhub]
|
|
86
|
+
command = "npx"
|
|
87
|
+
args = ["-y", "@synth-coder/memhub@latest"]
|
|
88
|
+
```
|
|
89
|
+
|
|
82
90
|
---
|
|
83
91
|
|
|
84
92
|
## Configure Your Agent
|
|
@@ -175,7 +183,7 @@ This means "testing framework preference" finds memories about "Vitest vs Jest d
|
|
|
175
183
|
- **Markdown Storage** — Human-readable `.md` files with YAML front matter
|
|
176
184
|
- **Git-Friendly** — Version control, diff, review your memories
|
|
177
185
|
- **MCP Protocol** — Works with Claude Code, Cursor, Cline, Windsurf, and more
|
|
178
|
-
- **One-Line Setup** — `npx -y @synth-coder/memhub init`
|
|
186
|
+
- **One-Line Setup** — `npx -y @synth-coder/memhub@latest init`
|
|
179
187
|
|
|
180
188
|
---
|
|
181
189
|
|
|
@@ -267,7 +275,7 @@ memhub/
|
|
|
267
275
|
- [x] CLI init command for quick setup
|
|
268
276
|
- [ ] Integration tests
|
|
269
277
|
- [ ] Performance improvements
|
|
270
|
-
- [x] npm release (`@synth-coder/memhub@0.2.
|
|
278
|
+
- [x] npm release (`@synth-coder/memhub@0.2.5`)
|
|
271
279
|
|
|
272
280
|
---
|
|
273
281
|
|