@fractary/codex 0.1.1 → 0.1.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/README.md +230 -280
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -1,280 +1,230 @@
|
|
|
1
|
-
# @fractary/codex
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@fractary/codex)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
|
|
173
|
-
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
]
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
npm test
|
|
232
|
-
|
|
233
|
-
# Test with coverage
|
|
234
|
-
npm run test:coverage
|
|
235
|
-
|
|
236
|
-
# Type check
|
|
237
|
-
npm run typecheck
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## Project Structure
|
|
241
|
-
|
|
242
|
-
```
|
|
243
|
-
src/
|
|
244
|
-
├── core/
|
|
245
|
-
│ ├── metadata/ # Frontmatter parsing
|
|
246
|
-
│ ├── patterns/ # Pattern matching
|
|
247
|
-
│ ├── routing/ # Sync routing logic
|
|
248
|
-
│ └── config/ # Configuration system
|
|
249
|
-
├── schemas/ # Zod schemas
|
|
250
|
-
├── errors/ # Error classes
|
|
251
|
-
└── index.ts # Main exports
|
|
252
|
-
|
|
253
|
-
tests/
|
|
254
|
-
├── unit/ # Unit tests
|
|
255
|
-
└── fixtures/ # Test fixtures
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
## Specifications
|
|
259
|
-
|
|
260
|
-
Detailed specifications are available in `/docs/specs/`:
|
|
261
|
-
|
|
262
|
-
- [SPEC-00001: Core SDK Overview](./docs/specs/SPEC-00001-core-sdk-overview.md)
|
|
263
|
-
- [SPEC-00002: Metadata Parsing](./docs/specs/SPEC-00002-metadata-parsing.md)
|
|
264
|
-
- [SPEC-00003: Pattern Matching](./docs/specs/SPEC-00003-pattern-matching.md)
|
|
265
|
-
- [SPEC-00004: Routing & Distribution](./docs/specs/SPEC-00004-routing-distribution.md)
|
|
266
|
-
- [SPEC-00005: Configuration System](./docs/specs/SPEC-00005-configuration-system.md)
|
|
267
|
-
|
|
268
|
-
## Related Projects
|
|
269
|
-
|
|
270
|
-
- **fractary-cli** - Unified CLI for all Fractary tools (coming soon)
|
|
271
|
-
- **forge-bundle-codex-github-core** - GitHub Actions workflows for codex sync
|
|
272
|
-
- **forge-bundle-codex-claude-agents** - Claude Code agents for codex management
|
|
273
|
-
|
|
274
|
-
## License
|
|
275
|
-
|
|
276
|
-
MIT © Fractary Engineering
|
|
277
|
-
|
|
278
|
-
## Contributing
|
|
279
|
-
|
|
280
|
-
This is part of the Fractary ecosystem. For issues or contributions, please refer to the [main repository](https://github.com/fractary/codex).
|
|
1
|
+
# @fractary/codex
|
|
2
|
+
|
|
3
|
+
JavaScript/TypeScript SDK for Fractary Codex - knowledge infrastructure for AI agents.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fractary/codex)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @fractary/codex
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Universal References**: `codex://` URI scheme for cross-project knowledge references
|
|
17
|
+
- **Multi-Provider Storage**: Local filesystem, GitHub, and HTTP storage backends
|
|
18
|
+
- **Intelligent Caching**: Multi-tier caching (L1 memory, L2 disk, L3 network) with LRU eviction
|
|
19
|
+
- **File Synchronization**: Bidirectional sync with conflict detection
|
|
20
|
+
- **MCP Integration**: Model Context Protocol server for AI agent integration
|
|
21
|
+
- **Permission System**: Fine-grained access control (none/read/write/admin)
|
|
22
|
+
- **Migration Tools**: Upgrade from v2.x to v3.0 configuration format
|
|
23
|
+
- **Type-Safe**: Full TypeScript support with strict typing
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
parseReference,
|
|
30
|
+
resolveReference,
|
|
31
|
+
CacheManager,
|
|
32
|
+
StorageManager,
|
|
33
|
+
createMcpServer
|
|
34
|
+
} from '@fractary/codex'
|
|
35
|
+
|
|
36
|
+
// Parse a codex URI
|
|
37
|
+
const ref = parseReference('codex://myorg/docs/api-guide.md')
|
|
38
|
+
console.log(ref.org) // 'myorg'
|
|
39
|
+
console.log(ref.path) // 'docs/api-guide.md'
|
|
40
|
+
|
|
41
|
+
// Create storage and cache managers
|
|
42
|
+
const storage = StorageManager.create()
|
|
43
|
+
const cache = CacheManager.create({ cacheDir: '.codex-cache' })
|
|
44
|
+
|
|
45
|
+
// Fetch content with caching
|
|
46
|
+
const content = await cache.get('codex://myorg/docs/api-guide.md')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Core Modules
|
|
50
|
+
|
|
51
|
+
### References
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { parseReference, buildUri, validateUri } from '@fractary/codex'
|
|
55
|
+
|
|
56
|
+
const ref = parseReference('codex://fractary/codex/docs/api.md')
|
|
57
|
+
const uri = buildUri('fractary', 'codex', 'docs/api.md')
|
|
58
|
+
const isValid = validateUri('codex://org/project/path.md')
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Storage
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { StorageManager } from '@fractary/codex'
|
|
65
|
+
|
|
66
|
+
const storage = StorageManager.create({
|
|
67
|
+
providers: [
|
|
68
|
+
{ type: 'local', basePath: './knowledge' },
|
|
69
|
+
{ type: 'github', token: process.env.GITHUB_TOKEN },
|
|
70
|
+
{ type: 'http', baseUrl: 'https://codex.example.com' }
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const result = await storage.fetch('codex://org/project/file.md')
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Cache
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { createCacheManager } from '@fractary/codex'
|
|
81
|
+
|
|
82
|
+
const cache = createCacheManager({
|
|
83
|
+
cacheDir: '.codex-cache',
|
|
84
|
+
maxMemorySize: 50 * 1024 * 1024,
|
|
85
|
+
defaultTtl: 3600
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const entry = await cache.get('codex://org/project/file.md')
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### MCP Server
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { createMcpServer } from '@fractary/codex'
|
|
95
|
+
|
|
96
|
+
const server = createMcpServer({
|
|
97
|
+
name: 'codex',
|
|
98
|
+
version: '1.0.0',
|
|
99
|
+
cacheDir: '.codex-cache'
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
await server.start()
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Install dependencies
|
|
109
|
+
npm install
|
|
110
|
+
|
|
111
|
+
# Build the package
|
|
112
|
+
npm run build
|
|
113
|
+
|
|
114
|
+
# Run tests
|
|
115
|
+
npm test
|
|
116
|
+
|
|
117
|
+
# Run tests in watch mode
|
|
118
|
+
npm run test:watch
|
|
119
|
+
|
|
120
|
+
# Type check
|
|
121
|
+
npm run typecheck
|
|
122
|
+
|
|
123
|
+
# Lint
|
|
124
|
+
npm run lint
|
|
125
|
+
|
|
126
|
+
# Format code
|
|
127
|
+
npm run format
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Publishing to npm
|
|
131
|
+
|
|
132
|
+
### Prerequisites
|
|
133
|
+
|
|
134
|
+
1. **npm Account**: Create an account on [npmjs.com](https://www.npmjs.com)
|
|
135
|
+
2. **npm Login**: Run `npm login` to authenticate
|
|
136
|
+
3. **Organization Access**: Ensure you have publish access to `@fractary` scope
|
|
137
|
+
|
|
138
|
+
### Manual Publishing
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Build and test
|
|
142
|
+
npm run build
|
|
143
|
+
npm test
|
|
144
|
+
|
|
145
|
+
# Check what will be published
|
|
146
|
+
npm pack --dry-run
|
|
147
|
+
|
|
148
|
+
# Publish to npm (the prepublishOnly script runs build & test automatically)
|
|
149
|
+
npm publish
|
|
150
|
+
|
|
151
|
+
# For first publish or after scope changes
|
|
152
|
+
npm publish --access public
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Automated Publishing (CI/CD)
|
|
156
|
+
|
|
157
|
+
For automated publishing via GitHub Actions:
|
|
158
|
+
|
|
159
|
+
1. **npm Token**: Generate an Automation token on npmjs.com
|
|
160
|
+
2. **GitHub Secret**: Add `NPM_TOKEN` to repository secrets
|
|
161
|
+
3. **Workflow**: Create `.github/workflows/npm-publish.yml`:
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
name: Publish to npm
|
|
165
|
+
on:
|
|
166
|
+
release:
|
|
167
|
+
types: [published]
|
|
168
|
+
|
|
169
|
+
jobs:
|
|
170
|
+
publish:
|
|
171
|
+
runs-on: ubuntu-latest
|
|
172
|
+
steps:
|
|
173
|
+
- uses: actions/checkout@v4
|
|
174
|
+
- uses: actions/setup-node@v4
|
|
175
|
+
with:
|
|
176
|
+
node-version: '20'
|
|
177
|
+
registry-url: 'https://registry.npmjs.org'
|
|
178
|
+
- run: npm ci
|
|
179
|
+
- run: npm run build
|
|
180
|
+
- run: npm test
|
|
181
|
+
- run: npm publish --access public
|
|
182
|
+
env:
|
|
183
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Version Management
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Bump patch version (0.1.2 -> 0.1.3)
|
|
190
|
+
npm version patch
|
|
191
|
+
|
|
192
|
+
# Bump minor version (0.1.2 -> 0.2.0)
|
|
193
|
+
npm version minor
|
|
194
|
+
|
|
195
|
+
# Bump major version (0.1.2 -> 1.0.0)
|
|
196
|
+
npm version major
|
|
197
|
+
|
|
198
|
+
# This automatically:
|
|
199
|
+
# - Updates package.json version
|
|
200
|
+
# - Creates a git commit
|
|
201
|
+
# - Creates a git tag
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
To publish a new version:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# 1. Ensure all changes are committed
|
|
208
|
+
# 2. Bump version
|
|
209
|
+
npm version patch # or minor/major
|
|
210
|
+
|
|
211
|
+
# 3. Push with tags
|
|
212
|
+
git push && git push --tags
|
|
213
|
+
|
|
214
|
+
# 4. Publish to npm
|
|
215
|
+
npm publish
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Follow [Semantic Versioning](https://semver.org/):
|
|
219
|
+
- **MAJOR**: Breaking API changes
|
|
220
|
+
- **MINOR**: New features, backward compatible
|
|
221
|
+
- **PATCH**: Bug fixes, backward compatible
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT - see [LICENSE](LICENSE)
|
|
226
|
+
|
|
227
|
+
## See Also
|
|
228
|
+
|
|
229
|
+
- [Python SDK](../python/) - `fractary-codex` on PyPI
|
|
230
|
+
- [Documentation](../../docs/)
|
package/dist/index.cjs
CHANGED