@redaksjon/protokoll 1.0.2 → 1.0.7

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.
@@ -0,0 +1,147 @@
1
+ # Bug Fix: Context Directory Discovery Issue
2
+
3
+ ## Problem
4
+
5
+ The Protokoll MCP tools were not finding context entities (projects, people, terms) even though they existed in the repository.
6
+
7
+ ### Symptoms
8
+
9
+ - Context files exist in: `/path/to/repo/context/projects/*.yaml`
10
+ - `.protokoll/config.yaml` exists but has no `contextDirectory` setting
11
+ - MCP tools look for context in: `/path/to/repo/.protokoll/` (the config directory)
12
+ - Result: `protokoll_list_projects` returns 0 projects even though 11 project YAML files exist
13
+
14
+ ### Expected Behavior
15
+
16
+ The context discovery should default to looking in `./context/` relative to the repository root, NOT in `.protokoll/context/`.
17
+
18
+ ## Root Cause
19
+
20
+ The context discovery logic in both `src/context/discovery.ts` and `src/overcontext/discovery.ts` was hardcoded to look for context in `.protokoll/context/`, but the actual context structure is:
21
+
22
+ ```
23
+ repo/
24
+ .protokoll/
25
+ config.yaml # Configuration file
26
+ context/ # Context entities (should be default)
27
+ projects/
28
+ people/
29
+ terms/
30
+ companies/
31
+ ```
32
+
33
+ ## Solution
34
+
35
+ Changed the default context discovery logic to:
36
+
37
+ 1. **Priority 1**: Use explicit `contextDirectory` from `config.yaml` if specified
38
+ 2. **Priority 2**: Look for `./context/` at repository root (sibling to `.protokoll/`)
39
+ 3. **Priority 3**: Fall back to `.protokoll/context/` for backward compatibility
40
+
41
+ ### Configuration Option
42
+
43
+ Added support for `contextDirectory` in `.protokoll/config.yaml`:
44
+
45
+ ```yaml
46
+ # Use a custom context directory
47
+ contextDirectory: ./my-custom-context
48
+
49
+ # Or use an absolute path
50
+ contextDirectory: /absolute/path/to/context
51
+ ```
52
+
53
+ If not specified, defaults to `./context/` at the repository root.
54
+
55
+ ## Changes Made
56
+
57
+ ### Files Modified
58
+
59
+ 1. **src/context/discovery.ts**
60
+ - Added `resolveContextDirectory()` function to implement the new priority logic
61
+ - Updated `loadHierarchicalConfig()` to use the new resolution logic
62
+
63
+ 2. **src/overcontext/discovery.ts**
64
+ - Added `resolveContextDirectory()` function (same implementation)
65
+ - Updated `loadHierarchicalConfig()` to use the new resolution logic
66
+
67
+ 3. **src/overcontext/adapter.ts**
68
+ - Updated `load()` method to work with the new context directory resolution
69
+ - Fixed import to include `redaksjonPluralNames`
70
+
71
+ ### Tests Added
72
+
73
+ 1. **tests/context/discovery.test.ts**
74
+ - Added test: "should prefer ./context/ at repository root over .protokoll/context/"
75
+ - Added test: "should use explicit contextDirectory from config.yaml"
76
+ - Added test: "should handle absolute contextDirectory path in config.yaml"
77
+ - Added test: "should fall back to default when explicit contextDirectory does not exist"
78
+ - Added test: "should handle no context directory found"
79
+
80
+ 2. **tests/context/bug-context-directory.test.ts** (new file)
81
+ - Comprehensive end-to-end tests for the bug fix
82
+ - Tests all three priority levels
83
+ - Tests backward compatibility
84
+
85
+ ## Test Results
86
+
87
+ All tests passing:
88
+ - 19/19 tests in `tests/context/discovery.test.ts`
89
+ - 4/4 tests in `tests/context/bug-context-directory.test.ts`
90
+ - All existing tests continue to pass (no regressions)
91
+
92
+ ## Backward Compatibility
93
+
94
+ The fix maintains full backward compatibility:
95
+ - Existing repositories with context in `.protokoll/context/` will continue to work
96
+ - No configuration changes required for existing setups
97
+ - New repositories can use the simpler `./context/` structure
98
+
99
+ ## Migration Guide
100
+
101
+ ### For New Repositories
102
+
103
+ Create context at the repository root:
104
+
105
+ ```bash
106
+ mkdir -p context/{projects,people,terms,companies}
107
+ ```
108
+
109
+ ### For Existing Repositories
110
+
111
+ Option 1: Move context to repository root (recommended):
112
+
113
+ ```bash
114
+ mv .protokoll/context ./context
115
+ ```
116
+
117
+ Option 2: Keep existing structure (no changes needed):
118
+
119
+ ```bash
120
+ # Context remains in .protokoll/context/
121
+ # Everything continues to work as before
122
+ ```
123
+
124
+ Option 3: Use custom location:
125
+
126
+ ```yaml
127
+ # .protokoll/config.yaml
128
+ contextDirectory: ./my-custom-location
129
+ ```
130
+
131
+ ## Verification
132
+
133
+ To verify the fix works:
134
+
135
+ ```bash
136
+ # List projects (should now find entities in ./context/)
137
+ protokoll list-projects
138
+
139
+ # Or via MCP
140
+ protokoll_list_projects()
141
+ ```
142
+
143
+ ## Related Issues
144
+
145
+ - Fixes context discovery for MCP tools
146
+ - Improves developer experience by supporting standard repository structure
147
+ - Maintains backward compatibility with existing setups
package/README.md CHANGED
@@ -2270,3 +2270,7 @@ Tim O'Brien <tobrien@discursive.com>
2270
2270
  TEST
2271
2271
  TEST
2272
2272
  TEST
2273
+ TEST
2274
+ TEST
2275
+ TEST
2276
+ TEST
package/dist/main.js CHANGED
@@ -8,8 +8,8 @@ import utc from 'dayjs/plugin/utc.js';
8
8
  import 'moment-timezone';
9
9
  import * as path$1 from 'node:path';
10
10
  import path__default from 'node:path';
11
- import * as Dreadcabinet from '@theunwalked/dreadcabinet';
12
- import * as Cardigantime from '@theunwalked/cardigantime';
11
+ import * as Dreadcabinet from '@utilarium/dreadcabinet';
12
+ import * as Cardigantime from '@utilarium/cardigantime';
13
13
  import { z } from 'zod';
14
14
  import { glob } from 'glob';
15
15
  import * as readline from 'readline';
@@ -26,7 +26,7 @@ import 'node:fs';
26
26
  import 'node:crypto';
27
27
  import 'node:fs/promises';
28
28
  import 'html-to-text';
29
- import '@theunwalked/overcontext';
29
+ import '@utilarium/overcontext';
30
30
  import '@redaksjon/context';
31
31
  import 'winston';
32
32