decision-os-mcp 0.3.2 → 0.4.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.
- package/AGENTS.md +69 -0
- package/README.md +38 -3
- package/package.json +11 -1
- package/templates/AGENTS.md +38 -0
- package/templates/claude-desktop-mcp-config.json +11 -0
- package/src/hierarchical-storage.ts +0 -505
- package/src/index.ts +0 -932
- package/src/schemas.ts +0 -296
- package/src/storage.ts +0 -829
- package/test/hierarchical-storage.test.ts +0 -223
- package/test/storage.test.ts +0 -551
- package/tsconfig.json +0 -19
package/src/schemas.ts
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// SIGNALS - Observable context for decisions
|
|
5
|
-
// ============================================================================
|
|
6
|
-
|
|
7
|
-
export const RiskLevel = z.enum(["LOW", "MEDIUM", "HIGH"]);
|
|
8
|
-
export const Reversibility = z.enum(["EASY", "MEDIUM", "HARD"]);
|
|
9
|
-
export const ChangeFrequency = z.enum(["RARE", "OCCASIONAL", "FREQUENT"]);
|
|
10
|
-
export const Novelty = z.enum(["LOW", "MEDIUM", "HIGH"]);
|
|
11
|
-
export const Uncertainty = z.enum(["LOW", "MEDIUM", "HIGH"]);
|
|
12
|
-
export const ValidationLevel = z.enum(["BASIC", "STANDARD", "STRICT"]);
|
|
13
|
-
export const Confidence = z.enum(["LOW", "MEDIUM", "HIGH"]);
|
|
14
|
-
|
|
15
|
-
// NOTE: Affected surface is intentionally a free-form string to allow
|
|
16
|
-
// project-specific extensions via `config.yaml` (e.g., GIS_SPATIAL).
|
|
17
|
-
// Keep the canonical values documented here for policy checks / UI hints.
|
|
18
|
-
export const AffectedSurfaceCore = z.enum([
|
|
19
|
-
"CORE_DOMAIN",
|
|
20
|
-
"INTEGRATION",
|
|
21
|
-
"DATA_MODEL",
|
|
22
|
-
"INFRA_DEPLOY",
|
|
23
|
-
"SECURITY_BOUNDARY",
|
|
24
|
-
"UI_UX",
|
|
25
|
-
"PERFORMANCE_CRITICAL",
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
export const DiffScope = z.enum(["LOCAL", "MULTI_MODULE", "CROSS_CUTTING"]);
|
|
29
|
-
export const DependencyChange = z.enum(["NONE", "MINOR", "MAJOR"]);
|
|
30
|
-
export const Regressions = z.enum(["NONE", "MINOR", "MAJOR"]);
|
|
31
|
-
export const Regret = z.enum(["0", "1", "2", "3"]);
|
|
32
|
-
export const RegretInput = z.preprocess((value) => {
|
|
33
|
-
// Accept 0..3 as numbers from loosely-typed callers, but store as strings.
|
|
34
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
35
|
-
return String(value);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}, Regret);
|
|
39
|
-
|
|
40
|
-
export const ContextSignals = z.object({
|
|
41
|
-
risk_level: RiskLevel.optional(),
|
|
42
|
-
reversibility: Reversibility.optional(),
|
|
43
|
-
change_frequency: ChangeFrequency.optional(),
|
|
44
|
-
affected_surface: z.array(z.string()).optional(),
|
|
45
|
-
novelty: Novelty.optional(),
|
|
46
|
-
repo_scope: z.string().optional(), // Project-specific, e.g., "BACKEND_ONLY"
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const ExecutionSignals = z.object({
|
|
50
|
-
diff_scope: DiffScope.optional(),
|
|
51
|
-
uncertainty: Uncertainty.optional(),
|
|
52
|
-
dependency_change: DependencyChange.optional(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export const OutcomeSignals = z.object({
|
|
56
|
-
regressions: Regressions.optional(),
|
|
57
|
-
rework_within_14d: z.boolean().optional(),
|
|
58
|
-
regret: Regret,
|
|
59
|
-
notes: z.string().optional(),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export type ContextSignals = z.infer<typeof ContextSignals>;
|
|
63
|
-
export type ExecutionSignals = z.infer<typeof ExecutionSignals>;
|
|
64
|
-
export type OutcomeSignals = z.infer<typeof OutcomeSignals>;
|
|
65
|
-
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// DECISIONS - The vocabulary for approach/posture
|
|
68
|
-
// ============================================================================
|
|
69
|
-
|
|
70
|
-
export const Approach = z.enum(["REUSE", "REFRAME", "BUILD", "HYBRID"]);
|
|
71
|
-
export const Posture = z.enum(["MINIMAL", "BALANCED", "ROBUST"]);
|
|
72
|
-
|
|
73
|
-
export const Decisions = z.object({
|
|
74
|
-
approach: Approach,
|
|
75
|
-
posture: Posture,
|
|
76
|
-
validation_level: ValidationLevel,
|
|
77
|
-
confidence: Confidence,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export type Decisions = z.infer<typeof Decisions>;
|
|
81
|
-
|
|
82
|
-
// ============================================================================
|
|
83
|
-
// PRESSURE EVENT - The primary learning artifact
|
|
84
|
-
// ============================================================================
|
|
85
|
-
|
|
86
|
-
export const PressureType = z.enum([
|
|
87
|
-
"CHANGE",
|
|
88
|
-
"IRREVERSIBILITY",
|
|
89
|
-
"COGNITIVE",
|
|
90
|
-
"COUPLING",
|
|
91
|
-
"OPERATIONAL",
|
|
92
|
-
"EXTERNAL",
|
|
93
|
-
]);
|
|
94
|
-
|
|
95
|
-
export const PressureEvent = z.object({
|
|
96
|
-
id: z.string(), // PE-0001
|
|
97
|
-
timestamp: z.string(), // ISO date
|
|
98
|
-
case_id: z.string(),
|
|
99
|
-
pressure_type: PressureType.optional(),
|
|
100
|
-
context_tags: z.array(z.string()).optional(),
|
|
101
|
-
expected: z.string(), // What we assumed
|
|
102
|
-
actual: z.string(), // What happened
|
|
103
|
-
adaptation: z.string(), // What we changed
|
|
104
|
-
remember: z.string(), // One-liner for potential foundation
|
|
105
|
-
outcome: z.string().optional(), // Filled later
|
|
106
|
-
promoted_to_foundation: z.string().optional(), // Foundation ID if promoted
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
export type PressureEvent = z.infer<typeof PressureEvent>;
|
|
110
|
-
|
|
111
|
-
// ============================================================================
|
|
112
|
-
// CASE - Bounded unit of work
|
|
113
|
-
// ============================================================================
|
|
114
|
-
|
|
115
|
-
export const CaseStatus = z.enum(["ACTIVE", "COMPLETED", "ABANDONED"]);
|
|
116
|
-
|
|
117
|
-
export const Case = z.object({
|
|
118
|
-
id: z.string(), // 0001-bootstrap-backend
|
|
119
|
-
title: z.string(),
|
|
120
|
-
goal: z.string().optional(),
|
|
121
|
-
status: CaseStatus.default("ACTIVE"),
|
|
122
|
-
created_at: z.string(),
|
|
123
|
-
completed_at: z.string().optional(),
|
|
124
|
-
context: z
|
|
125
|
-
.object({
|
|
126
|
-
repos: z.record(z.string()).optional(),
|
|
127
|
-
touched_areas: z.array(z.string()).optional(),
|
|
128
|
-
references: z
|
|
129
|
-
.object({
|
|
130
|
-
prs: z.array(z.string()).optional(),
|
|
131
|
-
commits: z.array(z.string()).optional(),
|
|
132
|
-
issues: z.array(z.string()).optional(),
|
|
133
|
-
})
|
|
134
|
-
.optional(),
|
|
135
|
-
})
|
|
136
|
-
.optional(),
|
|
137
|
-
signals: z
|
|
138
|
-
.object({
|
|
139
|
-
context: ContextSignals.optional(),
|
|
140
|
-
execution: ExecutionSignals.optional(),
|
|
141
|
-
outcome: OutcomeSignals.optional(),
|
|
142
|
-
})
|
|
143
|
-
.optional(),
|
|
144
|
-
decisions: Decisions.optional(),
|
|
145
|
-
pressure_events: z.array(z.string()).optional(), // PE-IDs
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
export type Case = z.infer<typeof Case>;
|
|
149
|
-
|
|
150
|
-
// ============================================================================
|
|
151
|
-
// FOUNDATION - Compressed learning
|
|
152
|
-
// ============================================================================
|
|
153
|
-
|
|
154
|
-
export const FoundationConfidence = z.union([
|
|
155
|
-
z.literal(0),
|
|
156
|
-
z.literal(1),
|
|
157
|
-
z.literal(2),
|
|
158
|
-
z.literal(3),
|
|
159
|
-
]);
|
|
160
|
-
|
|
161
|
-
export const FoundationScope = z.enum(["GLOBAL", "PROJECT"]);
|
|
162
|
-
|
|
163
|
-
export const Foundation = z.object({
|
|
164
|
-
id: z.string(), // F-0001 (project) or GF-0001 (global)
|
|
165
|
-
title: z.string(),
|
|
166
|
-
default_behavior: z.string(), // What to do
|
|
167
|
-
context_tags: z.array(z.string()), // When it applies
|
|
168
|
-
counter_contexts: z.array(z.string()).optional(), // When it doesn't
|
|
169
|
-
confidence: FoundationConfidence,
|
|
170
|
-
scope: FoundationScope.default("PROJECT"), // GLOBAL or PROJECT
|
|
171
|
-
origin_project: z.string().optional(), // Where it was first discovered
|
|
172
|
-
validated_in: z.array(z.string()).optional(), // Projects that confirmed this
|
|
173
|
-
exit_criteria: z.string().optional(), // When to reconsider
|
|
174
|
-
source_pressures: z.array(z.string()), // PE-IDs that led to this
|
|
175
|
-
created_at: z.string(),
|
|
176
|
-
updated_at: z.string(),
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
export type Foundation = z.infer<typeof Foundation>;
|
|
180
|
-
export type FoundationScope = z.infer<typeof FoundationScope>;
|
|
181
|
-
|
|
182
|
-
// ============================================================================
|
|
183
|
-
// PROJECT CONFIG
|
|
184
|
-
// ============================================================================
|
|
185
|
-
|
|
186
|
-
export const ConfigScope = z.enum(["GLOBAL", "PROJECT"]);
|
|
187
|
-
|
|
188
|
-
export const ProjectConfig = z.object({
|
|
189
|
-
project: z.string(),
|
|
190
|
-
version: z.number().default(1),
|
|
191
|
-
scope: ConfigScope.default("PROJECT"), // GLOBAL or PROJECT
|
|
192
|
-
signals: z
|
|
193
|
-
.object({
|
|
194
|
-
context: z.record(z.array(z.string())).optional(), // Extended signals
|
|
195
|
-
})
|
|
196
|
-
.optional(),
|
|
197
|
-
repos: z.record(z.string()).optional(),
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
export type ProjectConfig = z.infer<typeof ProjectConfig>;
|
|
201
|
-
export type ConfigScope = z.infer<typeof ConfigScope>;
|
|
202
|
-
|
|
203
|
-
// ============================================================================
|
|
204
|
-
// TOOL INPUT SCHEMAS
|
|
205
|
-
// ============================================================================
|
|
206
|
-
|
|
207
|
-
export const LogPressureInput = z.object({
|
|
208
|
-
case_id: z.string().optional(), // Uses active case if not specified
|
|
209
|
-
expected: z.string().describe("What you assumed would happen"),
|
|
210
|
-
actual: z.string().describe("What actually happened"),
|
|
211
|
-
adaptation: z.string().describe("What you changed in response"),
|
|
212
|
-
remember: z.string().describe("One-liner summary for future reference"),
|
|
213
|
-
pressure_type: PressureType.optional(),
|
|
214
|
-
context_tags: z.array(z.string()).optional(),
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
export const CreateCaseInput = z.object({
|
|
218
|
-
title: z.string().describe("Short descriptive title"),
|
|
219
|
-
goal: z.string().optional().describe("What success looks like"),
|
|
220
|
-
signals: ContextSignals.optional(),
|
|
221
|
-
touched_areas: z.array(z.string()).optional(),
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
export const CloseCaseInput = z.object({
|
|
225
|
-
case_id: z.string().optional(), // Uses active case if not specified
|
|
226
|
-
regret: RegretInput.describe("0=would choose same, 3=strong regret"),
|
|
227
|
-
notes: z.string().optional(),
|
|
228
|
-
regressions: Regressions.optional(),
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
export const GetFoundationsInput = z.object({
|
|
232
|
-
context_tags: z
|
|
233
|
-
.array(z.string())
|
|
234
|
-
.optional()
|
|
235
|
-
.describe("Filter by context tags"),
|
|
236
|
-
min_confidence: z
|
|
237
|
-
.number()
|
|
238
|
-
.min(0)
|
|
239
|
-
.max(3)
|
|
240
|
-
.optional()
|
|
241
|
-
.describe("Minimum confidence level"),
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
export const PromoteToFoundationInput = z.object({
|
|
245
|
-
title: z.string(),
|
|
246
|
-
default_behavior: z.string().describe("What to do when this applies"),
|
|
247
|
-
context_tags: z.array(z.string()),
|
|
248
|
-
counter_contexts: z.array(z.string()).optional(),
|
|
249
|
-
source_pressures: z.array(z.string()).describe("PE-IDs that led to this"),
|
|
250
|
-
exit_criteria: z.string().optional(),
|
|
251
|
-
scope: FoundationScope.optional().describe("GLOBAL or PROJECT (default: PROJECT)"),
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
export const ElevateFoundationInput = z.object({
|
|
255
|
-
foundation_id: z.string().describe("ID of the foundation to elevate (e.g., F-0001)"),
|
|
256
|
-
reason: z.string().optional().describe("Why this foundation is universal"),
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
export const ValidateFoundationInput = z.object({
|
|
260
|
-
foundation_id: z.string().describe("ID of the foundation to validate"),
|
|
261
|
-
validation_notes: z.string().optional().describe("Notes on how this applies in current project"),
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
export const CheckPolicyInput = z.object({
|
|
265
|
-
signals: ContextSignals,
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
export const SearchPressuresInput = z.object({
|
|
269
|
-
query: z.string().trim().min(1).describe("Search query"),
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
export const SetActiveCaseInput = z.object({
|
|
273
|
-
case_id: z.string().trim().min(1).describe("Case ID to set as active"),
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
export const QuickPressureInput = z.object({
|
|
277
|
-
case_id: z.string().optional(),
|
|
278
|
-
expected: z.string().describe("What you assumed would happen"),
|
|
279
|
-
actual: z.string().describe("What actually happened"),
|
|
280
|
-
remember: z.string().optional().describe("One-liner summary (auto-generated if omitted)"),
|
|
281
|
-
adaptation: z.string().optional().describe("What you changed (optional for quick capture)"),
|
|
282
|
-
pressure_type: PressureType.optional(),
|
|
283
|
-
context_tags: z.array(z.string()).optional(),
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
export type LogPressureInput = z.infer<typeof LogPressureInput>;
|
|
287
|
-
export type CreateCaseInput = z.infer<typeof CreateCaseInput>;
|
|
288
|
-
export type CloseCaseInput = z.infer<typeof CloseCaseInput>;
|
|
289
|
-
export type GetFoundationsInput = z.infer<typeof GetFoundationsInput>;
|
|
290
|
-
export type PromoteToFoundationInput = z.infer<typeof PromoteToFoundationInput>;
|
|
291
|
-
export type ElevateFoundationInput = z.infer<typeof ElevateFoundationInput>;
|
|
292
|
-
export type ValidateFoundationInput = z.infer<typeof ValidateFoundationInput>;
|
|
293
|
-
export type CheckPolicyInput = z.infer<typeof CheckPolicyInput>;
|
|
294
|
-
export type SearchPressuresInput = z.infer<typeof SearchPressuresInput>;
|
|
295
|
-
export type SetActiveCaseInput = z.infer<typeof SetActiveCaseInput>;
|
|
296
|
-
export type QuickPressureInput = z.infer<typeof QuickPressureInput>;
|