@synth-coder/memhub 0.2.2 → 0.2.3
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 -0
- package/.factory/commands/opsx-archive.md +155 -0
- package/.factory/commands/opsx-explore.md +171 -0
- package/.factory/commands/opsx-propose.md +104 -0
- package/.factory/skills/openspec-apply-change/SKILL.md +156 -0
- package/.factory/skills/openspec-archive-change/SKILL.md +114 -0
- package/.factory/skills/openspec-explore/SKILL.md +288 -0
- package/.factory/skills/openspec-propose/SKILL.md +110 -0
- package/.github/workflows/ci.yml +74 -74
- 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 +169 -26
- package/README.md +195 -195
- package/README.zh-CN.md +193 -193
- package/dist/src/contracts/mcp.js +34 -34
- package/dist/src/server/mcp-server.d.ts +8 -0
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/mcp-server.js +23 -2
- package/dist/src/server/mcp-server.js.map +1 -1
- package/dist/src/services/memory-service.d.ts +1 -0
- package/dist/src/services/memory-service.d.ts.map +1 -1
- package/dist/src/services/memory-service.js +125 -82
- package/dist/src/services/memory-service.js.map +1 -1
- package/docs/architecture-diagrams.md +368 -0
- package/docs/architecture.md +381 -349
- package/docs/contracts.md +190 -119
- package/docs/prompt-template.md +33 -79
- package/docs/proposals/mcp-typescript-sdk-refactor.md +568 -568
- package/docs/proposals/proposal-close-gates.md +58 -58
- package/docs/tool-calling-policy.md +101 -107
- package/docs/vector-search.md +306 -0
- package/package.json +59 -58
- package/src/contracts/index.ts +12 -12
- package/src/contracts/mcp.ts +222 -222
- package/src/contracts/schemas.ts +307 -307
- package/src/contracts/types.ts +410 -410
- package/src/index.ts +8 -8
- package/src/server/index.ts +5 -5
- package/src/server/mcp-server.ts +185 -161
- package/src/services/embedding-service.ts +114 -114
- package/src/services/index.ts +5 -5
- package/src/services/memory-service.ts +663 -621
- package/src/storage/frontmatter-parser.ts +243 -243
- package/src/storage/index.ts +6 -6
- package/src/storage/markdown-storage.ts +236 -236
- package/src/storage/vector-index.ts +160 -160
- package/src/utils/index.ts +5 -5
- package/src/utils/slugify.ts +63 -63
- package/test/contracts/schemas.test.ts +313 -313
- package/test/contracts/types.test.ts +21 -21
- package/test/frontmatter-parser-more.test.ts +94 -94
- package/test/server/mcp-server.test.ts +210 -169
- package/test/services/memory-service-edge.test.ts +248 -248
- package/test/services/memory-service.test.ts +278 -278
- package/test/storage/frontmatter-parser.test.ts +222 -222
- package/test/storage/markdown-storage.test.ts +216 -216
- package/test/storage/storage-edge.test.ts +238 -238
- package/test/storage/vector-index.test.ts +153 -153
- package/test/utils/slugify-edge.test.ts +94 -94
- package/test/utils/slugify.test.ts +68 -68
- package/tsconfig.json +25 -25
- package/tsconfig.test.json +8 -8
- package/vitest.config.ts +29 -29
|
@@ -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,26 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
## Dev Environment
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install dependencies
|
|
13
|
+
pnpm install
|
|
14
|
+
|
|
15
|
+
# Build
|
|
16
|
+
pnpm run build
|
|
17
|
+
|
|
18
|
+
# Quality gate (lint + typecheck + test + coverage)
|
|
19
|
+
pnpm run quality
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Key Commands
|
|
23
|
+
|
|
24
|
+
| Command | Description |
|
|
25
|
+
|---------|-------------|
|
|
26
|
+
| `pnpm run build` | Compile TypeScript |
|
|
27
|
+
| `pnpm run lint` | ESLint check |
|
|
28
|
+
| `pnpm run lint:fix` | Auto-fix lint issues |
|
|
29
|
+
| `pnpm run typecheck` | TypeScript type check |
|
|
30
|
+
| `pnpm run test` | Run Vitest tests |
|
|
31
|
+
| `pnpm run test:watch` | Watch mode tests |
|
|
32
|
+
| `pnpm run test:coverage` | Tests with coverage |
|
|
33
|
+
| `pnpm run quality` | Full quality gate |
|
|
34
|
+
| `pnpm vitest run -t "test name"` | Run specific test |
|
|
35
|
+
|
|
36
|
+
## Project Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
src/
|
|
40
|
+
contracts/ # Type definitions, Zod schemas, MCP contracts
|
|
41
|
+
server/ # MCP stdio server entry point
|
|
42
|
+
services/ # Business logic (MemoryService, EmbeddingService)
|
|
43
|
+
storage/ # Storage layer (Markdown, VectorIndex)
|
|
44
|
+
utils/ # Shared utilities (slugify, etc.)
|
|
45
|
+
test/ # Vitest unit tests mirroring src/ structure
|
|
46
|
+
docs/ # Documentation
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Coding Conventions
|
|
50
|
+
|
|
51
|
+
### TypeScript Style
|
|
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
|
+
### Code Organization
|
|
64
|
+
- Contracts first: define types and schemas before implementation
|
|
65
|
+
- TDD workflow: red → green → refactor
|
|
66
|
+
- One export per file preferred; barrel exports in `index.ts`
|
|
67
|
+
|
|
68
|
+
### Example Code Style
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Types with readonly fields
|
|
72
|
+
export interface Memory {
|
|
73
|
+
readonly id: UUID;
|
|
74
|
+
readonly tags: readonly string[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Service with explicit types
|
|
78
|
+
export class MemoryService {
|
|
79
|
+
constructor(private readonly config: MemoryServiceConfig) {}
|
|
80
|
+
|
|
81
|
+
async create(input: CreateMemoryInput): Promise<CreateResult> {
|
|
82
|
+
// implementation
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Zod schema for validation
|
|
87
|
+
export const MemorySchema = z.object({
|
|
88
|
+
id: z.string().uuid(),
|
|
89
|
+
tags: z.array(z.string()),
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Testing Guidelines
|
|
94
|
+
|
|
95
|
+
- Test coverage threshold: **>= 80%**
|
|
96
|
+
- Tests mirror `src/` structure in `test/` directory
|
|
97
|
+
- Use Vitest: `describe`, `it`, `expect` pattern
|
|
98
|
+
- Edge cases go in `*-edge.test.ts` files
|
|
99
|
+
- Run `pnpm run quality` before committing
|
|
100
|
+
|
|
101
|
+
## Documentation Guidelines
|
|
102
|
+
|
|
103
|
+
文档是代码契约的一部分,必须与实现保持同步。
|
|
104
|
+
|
|
105
|
+
### 何时更新文档
|
|
106
|
+
|
|
107
|
+
**必须更新文档的场景:**
|
|
108
|
+
|
|
109
|
+
1. **接口变更** — 新增、修改、删除 MCP 工具参数或返回值
|
|
110
|
+
2. **类型定义变更** — 修改 `src/contracts/types.ts` 中的类型
|
|
111
|
+
3. **Schema 变更** — 修改 `src/contracts/schemas.ts` 中的 Zod schema
|
|
112
|
+
4. **行为变更** — 工具的调用逻辑、错误处理、默认值发生变化
|
|
113
|
+
5. **版本发布** — package.json 版本号变更时,同步更新 README 中的版本引用
|
|
114
|
+
|
|
115
|
+
**文档与代码的对应关系:**
|
|
116
|
+
|
|
117
|
+
| 代码文件 | 对应文档 |
|
|
118
|
+
|---------|---------|
|
|
119
|
+
| `src/contracts/types.ts` | `docs/contracts.md`、`docs/architecture.md` |
|
|
120
|
+
| `src/contracts/schemas.ts` | `docs/contracts.md` |
|
|
121
|
+
| `src/contracts/mcp.ts` | `docs/contracts.md`、`docs/tool-calling-policy.md` |
|
|
122
|
+
| `package.json` (version) | `README.md` (Roadmap) |
|
|
123
|
+
|
|
124
|
+
### 文档更新流程
|
|
125
|
+
|
|
126
|
+
1. 修改代码后,检查相关文档是否需要同步
|
|
127
|
+
2. 对照代码实现校对文档描述
|
|
128
|
+
3. 移除文档中不存在于代码的参数/字段
|
|
129
|
+
4. 补充文档中缺失的新增参数/字段
|
|
130
|
+
5. 确保示例代码与实际类型定义一致
|
|
131
|
+
|
|
132
|
+
### 验证方法
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# 对比代码中的类型定义与文档描述
|
|
136
|
+
grep -A 20 "interface MemoryLoadInput" src/contracts/types.ts
|
|
137
|
+
grep -A 20 "MemoryLoadInput" docs/contracts.md
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Git Workflow
|
|
141
|
+
|
|
142
|
+
- Commit message format: `type: description` (feat/fix/docs/chore/refactor/test)
|
|
143
|
+
- Always run quality gate before committing
|
|
144
|
+
- PR title format: `[scope] Description`
|
|
145
|
+
|
|
146
|
+
## Dos and Don'ts
|
|
147
|
+
|
|
148
|
+
### Do
|
|
149
|
+
- Run `pnpm run quality` before committing
|
|
150
|
+
- Add tests for new code
|
|
151
|
+
- Use `import type` for type-only imports
|
|
152
|
+
- Keep functions small and focused
|
|
153
|
+
- Update types and schemas together
|
|
154
|
+
|
|
155
|
+
### Don't
|
|
156
|
+
- Skip the quality gate
|
|
157
|
+
- Use `any` without justification
|
|
158
|
+
- Mutate function parameters
|
|
159
|
+
- Add code without corresponding tests
|
|
160
|
+
- Commit directly to main (use branches for features)
|
|
161
|
+
|
|
162
|
+
## MCP Tool Reference
|
|
163
|
+
|
|
164
|
+
MemHub exposes two primary tools:
|
|
165
|
+
|
|
166
|
+
1. **memory_load** - First-turn tool to load STM context
|
|
167
|
+
2. **memory_update** - Final-turn tool to write back decisions/knowledge
|
|
168
|
+
|
|
169
|
+
See `docs/tool-calling-policy.md` for detailed usage patterns.
|