codecall 1.0.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/ARCHITECTURE.md +553 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +109 -0
- package/dist/install-skill.d.ts +4 -0
- package/dist/install-skill.js +40 -0
- package/dist/policy/opportunity.d.ts +12 -0
- package/dist/policy/opportunity.js +126 -0
- package/dist/public.d.ts +12 -0
- package/dist/public.js +24 -0
- package/dist/runtime/event-store.d.ts +20 -0
- package/dist/runtime/event-store.js +32 -0
- package/dist/runtime/orchestrator.d.ts +28 -0
- package/dist/runtime/orchestrator.js +128 -0
- package/dist/runtime/reducer.d.ts +3 -0
- package/dist/runtime/reducer.js +43 -0
- package/dist/schemas/types.d.ts +136 -0
- package/dist/schemas/types.js +1 -0
- package/dist/schemas/validate.d.ts +3 -0
- package/dist/schemas/validate.js +17 -0
- package/dist/shared/id.d.ts +1 -0
- package/dist/shared/id.js +2 -0
- package/dist/workers/contracts.d.ts +25 -0
- package/dist/workers/contracts.js +1 -0
- package/dist/workers/default-workers.d.ts +29 -0
- package/dist/workers/default-workers.js +92 -0
- package/package.json +55 -0
- package/skill/SKILL.md +100 -0
- package/skill/agents/openai.yaml +4 -0
- package/skill/references/AGENTS.codecall.md +7 -0
- package/skill/references/CLAUDE.codecall.md +7 -0
- package/skill/references/trigger-policy.md +42 -0
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
# `codecall` MVP architecture proposal
|
|
2
|
+
|
|
3
|
+
## 1. Purpose and product boundary
|
|
4
|
+
|
|
5
|
+
`codecall` is an agent-native capability invoked after an implementation. It turns
|
|
6
|
+
evidence from that implementation into a short, adaptive learning session. It
|
|
7
|
+
does **not** generate generic documentation, replay a commit, or interrupt a
|
|
8
|
+
developer without consent.
|
|
9
|
+
|
|
10
|
+
The MVP has one public entry point:
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
codecall()
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Provider adapters may expose it as `/codecall`, a tool call, or an agent-suggested
|
|
17
|
+
card, but the domain runtime is provider-neutral. A recommendation is an
|
|
18
|
+
optional `LearningOpportunity`; it never starts a session itself.
|
|
19
|
+
|
|
20
|
+
### MVP outcomes
|
|
21
|
+
|
|
22
|
+
- decide whether there is a worthwhile learning opportunity;
|
|
23
|
+
- teach implementation-specific concepts in dependency order;
|
|
24
|
+
- adapt depth from a developer's declared confidence and answers;
|
|
25
|
+
- assess reasoning using MCQ questions grounded in the implementation;
|
|
26
|
+
- return a concise, reproducible summary.
|
|
27
|
+
|
|
28
|
+
### Explicit non-goals
|
|
29
|
+
|
|
30
|
+
- persistence across sessions, spaced repetition, analytics, a standalone UI,
|
|
31
|
+
repository-wide indexing, or automatic interruption;
|
|
32
|
+
- claiming a user has mastered a topic from one short quiz;
|
|
33
|
+
- collecting or exporting source code telemetry by default.
|
|
34
|
+
|
|
35
|
+
## 2. Design decisions and principles
|
|
36
|
+
|
|
37
|
+
| Decision | Recommendation | Why |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| Runtime | Reducer-driven, resumable orchestration engine | Event history makes every session inspectable and replayable. |
|
|
40
|
+
| Context | Progressive, budgeted evidence acquisition | Keeps sessions fast and avoids unnecessary repository exposure. |
|
|
41
|
+
| Reasoning | LLM workers over typed inputs/outputs | Extraction and pedagogy are judgment tasks, but contracts prevent prompt-only coupling. |
|
|
42
|
+
| Determinism | Deterministic policy, validation, state transitions, budgets, and event emission | Reproducible control flow without pretending teaching content is deterministic. |
|
|
43
|
+
| Persistence | Caller-owned event log/checkpoint for MVP | No hidden state; providers choose local file, memory, or encrypted store. |
|
|
44
|
+
| Documentation | Ranked provider registry, retrieval only when it adds value | Official sources strengthen claims while preserving offline/model-knowledge fallback. |
|
|
45
|
+
| UX | Streaming events plus explicit user gates | A provider can render progress, cancellation, and answers without exposing workers. |
|
|
46
|
+
|
|
47
|
+
The runtime must never silently widen context. Each context request records its
|
|
48
|
+
purpose, scope, budget, result, and whether it was denied or unavailable.
|
|
49
|
+
|
|
50
|
+
## 3. Component diagram
|
|
51
|
+
|
|
52
|
+
```mermaid
|
|
53
|
+
flowchart TD
|
|
54
|
+
P[Provider adapter: Codex / Claude Code / future] --> API[codecall public API]
|
|
55
|
+
API --> O[Session orchestrator]
|
|
56
|
+
O <--> S[Event store + reducer]
|
|
57
|
+
O --> C[Context collector]
|
|
58
|
+
O --> D[Opportunity detector]
|
|
59
|
+
O --> X[Concept extractor]
|
|
60
|
+
O --> L[Learning planner]
|
|
61
|
+
O --> F[Confidence assessor]
|
|
62
|
+
O --> R[Documentation resolver]
|
|
63
|
+
O --> T[Teaching engine]
|
|
64
|
+
O --> Q[Adaptive quiz engine]
|
|
65
|
+
O --> E[Evaluation engine]
|
|
66
|
+
C --> A[Repository / diff / conversation adapters]
|
|
67
|
+
R --> DR[Documentation-provider registry]
|
|
68
|
+
T --> M[LLM gateway]
|
|
69
|
+
Q --> M
|
|
70
|
+
E --> M
|
|
71
|
+
O --> EB[Event bus]
|
|
72
|
+
EB --> P
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`O` owns sequencing only. Workers cannot call each other, mutate session state,
|
|
76
|
+
nor emit provider-specific content; they receive a typed request and return a
|
|
77
|
+
typed result plus evidence references.
|
|
78
|
+
|
|
79
|
+
## 4. Public API
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
export interface LearnCapability {
|
|
83
|
+
start(input: StartSessionInput, deps: RuntimeDependencies): AsyncIterable<LearnEvent>;
|
|
84
|
+
answer(input: SubmitAnswerInput, deps: RuntimeDependencies): AsyncIterable<LearnEvent>;
|
|
85
|
+
cancel(input: CancelSessionInput, deps: RuntimeDependencies): AsyncIterable<LearnEvent>;
|
|
86
|
+
resume(input: ResumeSessionInput, deps: RuntimeDependencies): AsyncIterable<LearnEvent>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface StartSessionInput {
|
|
90
|
+
invocation: 'manual' | 'recommended';
|
|
91
|
+
implementation: ImplementationLocator;
|
|
92
|
+
user?: { id?: string; locale?: string };
|
|
93
|
+
options?: { maxMinutes?: number; offline?: boolean; privacyMode?: 'local-only' | 'allow-doc-fetch' };
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`start` emits an opportunity before requesting confidence. If recommendation is
|
|
98
|
+
declined, it emits `SESSION_CANCELLED` with reason `user_declined`; no teaching
|
|
99
|
+
or documentation retrieval occurs. `answer` and `resume` take the latest event
|
|
100
|
+
sequence/checkpoint, never an opaque server-side session identifier alone.
|
|
101
|
+
|
|
102
|
+
## 5. Runtime sequence
|
|
103
|
+
|
|
104
|
+
```mermaid
|
|
105
|
+
sequenceDiagram
|
|
106
|
+
participant U as Developer
|
|
107
|
+
participant A as Provider adapter
|
|
108
|
+
participant O as Orchestrator
|
|
109
|
+
participant W as Workers
|
|
110
|
+
participant DS as Documentation provider
|
|
111
|
+
U->>A: /codecall or Start Learning
|
|
112
|
+
A->>O: start(implementation locator)
|
|
113
|
+
O-->>A: SESSION_STARTED
|
|
114
|
+
O->>W: collect minimal context
|
|
115
|
+
W-->>O: context + evidence
|
|
116
|
+
O->>W: detect opportunity; extract concepts; make plan
|
|
117
|
+
W-->>O: opportunity + plan
|
|
118
|
+
O-->>A: LEARNING_RECOMMENDATION
|
|
119
|
+
U->>A: start / skip
|
|
120
|
+
alt skipped
|
|
121
|
+
A->>O: cancel(user_declined)
|
|
122
|
+
O-->>A: SESSION_CANCELLED
|
|
123
|
+
else started
|
|
124
|
+
A->>O: confidence answers
|
|
125
|
+
O->>W: resolve docs and teach the smallest next learning step
|
|
126
|
+
W->>DS: optional authoritative lookup
|
|
127
|
+
DS-->>W: cited sources or unavailable
|
|
128
|
+
O-->>A: LESSON_READY
|
|
129
|
+
loop adaptive teach-check loop
|
|
130
|
+
U->>A: answer a single check-in question
|
|
131
|
+
A->>O: submitAnswer
|
|
132
|
+
O->>W: evaluate understanding and select the next teaching move
|
|
133
|
+
O-->>A: feedback, a deeper explanation, a worked example, or one next question
|
|
134
|
+
end
|
|
135
|
+
O-->>A: SESSION_FINISHED + summary
|
|
136
|
+
end
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 6. Formal state machine
|
|
140
|
+
|
|
141
|
+
```mermaid
|
|
142
|
+
stateDiagram-v2
|
|
143
|
+
[*] --> Idle
|
|
144
|
+
Idle --> CollectingContext: START
|
|
145
|
+
CollectingContext --> Analyzing: CONTEXT_READY
|
|
146
|
+
CollectingContext --> Recovering: context failure
|
|
147
|
+
Analyzing --> Planning: concepts extracted
|
|
148
|
+
Planning --> WaitingForDecision: recommendation ready
|
|
149
|
+
WaitingForDecision --> Cancelled: decline/cancel
|
|
150
|
+
WaitingForDecision --> WaitingForConfidence: accept
|
|
151
|
+
WaitingForConfidence --> Teaching: confidence submitted
|
|
152
|
+
Teaching --> Quiz: lesson acknowledged
|
|
153
|
+
Quiz --> Evaluation: answer submitted
|
|
154
|
+
Evaluation --> Teaching: reinforce or next lesson
|
|
155
|
+
Evaluation --> Quiz: follow-up question
|
|
156
|
+
Evaluation --> Summary: objectives complete
|
|
157
|
+
Summary --> Completed: summary delivered
|
|
158
|
+
Recovering --> CollectingContext: retry with narrower source
|
|
159
|
+
Recovering --> WaitingForDecision: degraded plan available
|
|
160
|
+
Recovering --> Failed: unrecoverable error
|
|
161
|
+
CollectingContext --> Cancelled: cancel
|
|
162
|
+
Analyzing --> Cancelled: cancel
|
|
163
|
+
Planning --> Cancelled: cancel
|
|
164
|
+
Teaching --> Cancelled: cancel
|
|
165
|
+
Quiz --> Cancelled: cancel
|
|
166
|
+
Recovering --> Cancelled: cancel
|
|
167
|
+
Completed --> [*]
|
|
168
|
+
Cancelled --> [*]
|
|
169
|
+
Failed --> [*]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Recovery is not a vague catch-all. It has classified causes: unavailable source,
|
|
173
|
+
budget exhausted, invalid worker result, documentation failure, LLM failure, or
|
|
174
|
+
provider disconnect. The reducer retries only idempotent operations. A restart
|
|
175
|
+
uses the event history and `operationId` to avoid duplicate lessons or answers.
|
|
176
|
+
|
|
177
|
+
## 7. Data flow and progressive context
|
|
178
|
+
|
|
179
|
+
```mermaid
|
|
180
|
+
flowchart LR
|
|
181
|
+
I[Implementation locator] --> M[Minimal evidence: conversation + git diff + changed-file metadata]
|
|
182
|
+
M --> G{Enough to identify concepts?}
|
|
183
|
+
G -- yes --> E[Evidence pack]
|
|
184
|
+
G -- no --> F[Focused file excerpts]
|
|
185
|
+
F --> H{Dependency unclear?}
|
|
186
|
+
H -- yes --> J[Targeted symbol/repository search]
|
|
187
|
+
H -- no --> E
|
|
188
|
+
J --> K{Still blocked?}
|
|
189
|
+
K -- only if policy allows --> R[Bounded repository slice]
|
|
190
|
+
K -- no --> E
|
|
191
|
+
R --> E
|
|
192
|
+
E --> X[Structured concepts] --> P[Plan] --> L[Lessons and questions] --> S[Summary]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The default acquisition ladder is:
|
|
196
|
+
|
|
197
|
+
1. conversation task/result, changed-file paths, and diff summary;
|
|
198
|
+
2. bounded excerpts from changed files around relevant symbols;
|
|
199
|
+
3. targeted symbol definitions, direct imports/callers, and narrow search hits;
|
|
200
|
+
4. a declared bounded repository slice only when an unresolved dependency blocks
|
|
201
|
+
a learning claim.
|
|
202
|
+
|
|
203
|
+
There is no default “entire repository” step. The collector enforces file,
|
|
204
|
+
byte, token, duration, and sensitive-path budgets. Each excerpt carries a
|
|
205
|
+
stable `EvidenceRef` (path, revision, line span, hash) so later teaching can
|
|
206
|
+
cite what it actually used.
|
|
207
|
+
|
|
208
|
+
## 8. Workers and responsibilities
|
|
209
|
+
|
|
210
|
+
| Worker | Sole responsibility | Must not do |
|
|
211
|
+
| --- | --- | --- |
|
|
212
|
+
| Context collector | Acquire the smallest evidence pack that satisfies a declared question | Judge learning value or teach |
|
|
213
|
+
| Opportunity detector | Score whether a session is worthwhile and estimate duration | Extract detailed pedagogical concepts |
|
|
214
|
+
| Concept extractor | Produce the concept IR, evidence links, and misconceptions | Decide final teaching sequence |
|
|
215
|
+
| Learning planner | Build a deduplicated dependency-aware plan | Fetch docs or write prose |
|
|
216
|
+
| Confidence assessor | Collect and normalize user confidence per plan unit | Infer confidence from coding speed |
|
|
217
|
+
| Documentation resolver | Find/rank authoritative sources for requested concepts | Author lessons |
|
|
218
|
+
| Teaching engine | Produce one implementation-grounded lesson | Change session policy or quiz outcomes |
|
|
219
|
+
| Adaptive quiz engine | Generate the next reasoning-focused MCQ | Declare mastery |
|
|
220
|
+
| Evaluation engine | Grade response, diagnose misconception, choose reinforcement signal | Render UI or persist state |
|
|
221
|
+
| Summary builder | Derive the final summary from plan, evidence, and evaluations | Invent unobserved learning |
|
|
222
|
+
|
|
223
|
+
The orchestrator coordinates workers and validates contracts. A policy module
|
|
224
|
+
owns thresholds, budget rules, and the allowed state transitions; it is not a
|
|
225
|
+
worker because its behavior must be deterministic and versioned.
|
|
226
|
+
|
|
227
|
+
## 9. Internal contracts
|
|
228
|
+
|
|
229
|
+
All contracts are versioned, JSON-serializable, validated at every worker
|
|
230
|
+
boundary, and stored with the prompt/template and model metadata needed for
|
|
231
|
+
replay. Illustrative TypeScript shapes:
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
type SessionState =
|
|
235
|
+
| 'idle' | 'collecting_context' | 'analyzing' | 'planning'
|
|
236
|
+
| 'waiting_for_decision' | 'waiting_for_confidence' | 'teaching'
|
|
237
|
+
| 'quiz' | 'evaluation' | 'summary' | 'completed' | 'cancelled'
|
|
238
|
+
| 'recovering' | 'failed';
|
|
239
|
+
|
|
240
|
+
interface Session {
|
|
241
|
+
schemaVersion: 1;
|
|
242
|
+
id: string; state: SessionState; createdAt: string;
|
|
243
|
+
implementation: ImplementationLocator; policyVersion: string;
|
|
244
|
+
eventSequence: number; evidence: EvidencePack; plan?: LearningPlan;
|
|
245
|
+
currentUnitId?: string; failures: RecoveryRecord[];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface ImplementationContext {
|
|
249
|
+
revision?: string; task?: string; diff?: DiffSummary;
|
|
250
|
+
changedFiles: ChangedFile[]; excerpts: EvidenceRef[];
|
|
251
|
+
unresolvedQuestions: ContextQuestion[]; budget: ContextBudget;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface LearningOpportunity {
|
|
255
|
+
score: number; confidence: number; estimatedMinutes: number;
|
|
256
|
+
recommendation: 'recommend' | 'optional' | 'skip';
|
|
257
|
+
signals: OpportunitySignal[]; reasoning: string[];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
interface Concept {
|
|
261
|
+
id: string; label: string;
|
|
262
|
+
category: 'technology' | 'concept' | 'pattern' | 'anti_pattern' | 'architecture_decision' | 'misconception';
|
|
263
|
+
description: string; evidence: EvidenceRef[]; prerequisites: string[];
|
|
264
|
+
difficulty: 1 | 2 | 3 | 4 | 5; novelty: number; implementationRelevance: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
interface LearningPlan {
|
|
268
|
+
units: LearningUnit[]; dependencyEdges: DependencyEdge[];
|
|
269
|
+
estimatedMinutes: number; objectives: LearningObjective[];
|
|
270
|
+
omittedConcepts: Omission[];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
interface DocumentationResult {
|
|
274
|
+
conceptId: string; status: 'resolved' | 'unavailable' | 'not_needed';
|
|
275
|
+
sources: DocumentationSource[]; retrievalNotes: string[];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface Lesson {
|
|
279
|
+
unitId: string; objective: string; what: string; whyHere: string;
|
|
280
|
+
failureMode: string; connections: string[]; misconceptions: string[];
|
|
281
|
+
mentalModel: string; minimalExample: CodeExample; evidence: EvidenceRef[];
|
|
282
|
+
citations: DocumentationSource[];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface Question {
|
|
286
|
+
id: string; unitId: string; prompt: string; choices: Choice[];
|
|
287
|
+
correctChoiceId: string; rationales: Record<string, string>;
|
|
288
|
+
evidence: EvidenceRef[]; intent: 'causal_reasoning' | 'tradeoff' | 'debugging' | 'system_design';
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface Evaluation {
|
|
292
|
+
questionId: string; correct: boolean; confidenceDelta: number;
|
|
293
|
+
diagnosedMisconceptions: string[]; action: 'advance' | 'reinforce' | 'retry'; rationale: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface Summary {
|
|
297
|
+
conceptsLearned: LearnedConcept[]; weakAreas: WeakArea[];
|
|
298
|
+
estimatedMastery: MasteryEstimate; takeaways: string[];
|
|
299
|
+
pointsToRemember: string[]; edgeCasesForOtherProjects: string[];
|
|
300
|
+
limitations: string[];
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
`Concept.category` is deliberately singular. A relationship, such as a pattern
|
|
305
|
+
implemented with a technology, lives in typed links; this prevents categories
|
|
306
|
+
from collapsing into one ambiguous list.
|
|
307
|
+
|
|
308
|
+
## 10. Opportunity scoring and planning policy
|
|
309
|
+
|
|
310
|
+
The agent-backed product uses the shared skill policy as the authority; the
|
|
311
|
+
deterministic runtime mirrors it for local demonstrations and parity tests. It
|
|
312
|
+
does not infer learning value from LOC or file count.
|
|
313
|
+
|
|
314
|
+
An implementation is eligible only after completion and with inspectable task,
|
|
315
|
+
conversation, or changed-file evidence. It receives `recommend` when it has one
|
|
316
|
+
strong signal or two distinct moderate signals. Strong signals are an external
|
|
317
|
+
contract/integration, architecture or cross-component flow, a security or
|
|
318
|
+
reliability boundary, or a consequential tradeoff. Moderate signals are a
|
|
319
|
+
reusable pattern/lifecycle, a connected dependency relationship, or an
|
|
320
|
+
operational configuration, observability, validation, test-strategy, or
|
|
321
|
+
deployment change. One moderate signal is `optional`; no qualifying evidence is
|
|
322
|
+
`skip`.
|
|
323
|
+
|
|
324
|
+
Formatting, copy, comments, mechanical renames, generated-only files, isolated
|
|
325
|
+
dependency bumps, straightforward local fixes, and tests without a transferable
|
|
326
|
+
strategy do not produce automatic cards. Every result records matched strong and
|
|
327
|
+
moderate signals, excluded categories, an evidence-backed reason, and a stable
|
|
328
|
+
concept fingerprint. A runtime-local set suppresses repeated evaluation of the
|
|
329
|
+
same fingerprint; no learner history is persisted across sessions or projects.
|
|
330
|
+
|
|
331
|
+
Only `recommend` renders a non-blocking Start/Skip card. `optional` and `skip`
|
|
332
|
+
leave manual `/codecall` or `$codecall` available. No outcome starts teaching without
|
|
333
|
+
developer consent.
|
|
334
|
+
|
|
335
|
+
The planner removes duplicate concepts by canonical identity plus scope, merges
|
|
336
|
+
closely related nodes into a unit only when their prerequisites and objective
|
|
337
|
+
match, and topologically orders dependencies. It produces a **learning graph**,
|
|
338
|
+
not a fixed lesson/quiz script: each unit has mastery signals, prerequisite
|
|
339
|
+
edges, and alternative next moves. The runtime normally starts with the
|
|
340
|
+
highest-value prerequisite-ready unit and stops when the developer has met the
|
|
341
|
+
session objective or budget. It prioritizes architecture decisions and causal
|
|
342
|
+
links over vocabulary. Estimated time is derived from likely teaching moves,
|
|
343
|
+
confidence adjustment, and check-ins—not implementation size.
|
|
344
|
+
|
|
345
|
+
## 11. Teaching and quiz policy
|
|
346
|
+
|
|
347
|
+
For every unit, the teaching engine must answer: what it is; why this code
|
|
348
|
+
needed it; what fails without it; how it connects to adjacent units; common
|
|
349
|
+
misconceptions; a mental model; and a minimal example. Claims about the
|
|
350
|
+
implementation cite `EvidenceRef`s. If evidence is weak, the lesson states the
|
|
351
|
+
assumption rather than presenting it as fact.
|
|
352
|
+
|
|
353
|
+
The confidence gate asks one selectable level per unit or grouped prerequisite:
|
|
354
|
+
`expert`, `comfortable`, `heard_of_it`, `never_learned`. Users may skip, which
|
|
355
|
+
selects a neutral baseline. Confidence controls pace and question difficulty;
|
|
356
|
+
it never hides foundational prerequisite units that are necessary to understand
|
|
357
|
+
the implementation.
|
|
358
|
+
|
|
359
|
+
Questions are MCQ-only for MVP and must be implementation-aware. They are
|
|
360
|
+
**single check-ins**, introduced immediately after enough teaching to make a
|
|
361
|
+
reasoning judgment meaningful—not queued and thrown at the developer together.
|
|
362
|
+
For each concept unit, use two complementary checks: a real-world scenario
|
|
363
|
+
mapped explicitly back to the implementation mechanism, followed by a technical
|
|
364
|
+
application, dependency, tradeoff, or debugging question. Distractors represent
|
|
365
|
+
plausible misconceptions, and each choice has an explanation. The evaluator
|
|
366
|
+
uses the answer, confidence, and observed evidence to select the next learning
|
|
367
|
+
move: `advance`, `deepen`, `reinforce`, `retry`, or `finish`. A correct first
|
|
368
|
+
answer advances to the technical check for the same concept; uncertainty may
|
|
369
|
+
lead to a simpler mental model; an incorrect response first teaches the
|
|
370
|
+
diagnosed gap and only then asks a new isomorphic question. The system stops
|
|
371
|
+
asking questions once it has enough evidence for the session objective; it does
|
|
372
|
+
not chase a preset question count.
|
|
373
|
+
|
|
374
|
+
## 12. Event model, observability, and replay
|
|
375
|
+
|
|
376
|
+
Events are append-only records with `sessionId`, `sequence`, timestamp,
|
|
377
|
+
`operationId`, actor, contract version, sanitized payload, and correlation ID.
|
|
378
|
+
The reducer is the only component that transitions state.
|
|
379
|
+
|
|
380
|
+
Core events:
|
|
381
|
+
|
|
382
|
+
```text
|
|
383
|
+
SESSION_STARTED, CONTEXT_REQUESTED, CONTEXT_READY, CONTEXT_DEGRADED,
|
|
384
|
+
OPPORTUNITY_DETECTED, CONCEPTS_EXTRACTED, PLAN_CREATED,
|
|
385
|
+
LEARNING_RECOMMENDATION_PRESENTED, DECISION_RECORDED,
|
|
386
|
+
CONFIDENCE_RECORDED, DOCUMENTATION_RESOLVED, LESSON_STARTED, LESSON_READY,
|
|
387
|
+
QUESTION_PRESENTED, QUESTION_ANSWERED, ANSWER_EVALUATED, REINFORCEMENT_READY,
|
|
388
|
+
QUIZ_COMPLETED, SUMMARY_READY, SESSION_FINISHED, SESSION_CANCELLED,
|
|
389
|
+
OPERATION_FAILED, RECOVERY_STARTED, RECOVERY_SUCCEEDED, SESSION_FAILED
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
The public stream is a projection of these events. Raw prompts, source excerpts,
|
|
393
|
+
and answer text remain local by default; observability exposes timing, contract
|
|
394
|
+
validation failures, budget use, and redacted diagnostic codes. Event-log
|
|
395
|
+
replay must reproduce decisions for the same policy/template/model outputs;
|
|
396
|
+
LLM output is recorded or content-addressed so replay does not require a new
|
|
397
|
+
model call.
|
|
398
|
+
|
|
399
|
+
## 13. Documentation system
|
|
400
|
+
|
|
401
|
+
`DocumentationProvider` has `canResolve(concept)`, `search(query, budget)`,
|
|
402
|
+
and `fetch(sourceId)` contracts. The resolver ranks results by authority,
|
|
403
|
+
concept match, version match, stability, and accessibility. Default provider
|
|
404
|
+
order: language/framework/package official docs, standards/RFCs, project-local
|
|
405
|
+
docs, then model knowledge marked `uncited`.
|
|
406
|
+
|
|
407
|
+
Documentation fetch is optional and user-policy controlled. It has a strict
|
|
408
|
+
domain allowlist per provider, timeout/byte limits, content sanitization, and
|
|
409
|
+
source/version metadata. Offline mode disables network providers and visibly
|
|
410
|
+
labels model-only explanations. Documentation is evidence for a teaching claim,
|
|
411
|
+
not a replacement for implementation evidence.
|
|
412
|
+
|
|
413
|
+
## 14. Repository structure
|
|
414
|
+
|
|
415
|
+
```text
|
|
416
|
+
codecall/
|
|
417
|
+
├── README.md
|
|
418
|
+
├── ARCHITECTURE.md
|
|
419
|
+
├── package.json
|
|
420
|
+
├── src/
|
|
421
|
+
│ ├── public/ # codecall(), provider-neutral facade
|
|
422
|
+
│ ├── runtime/ # orchestrator, reducer, state machine, recovery
|
|
423
|
+
│ ├── workers/ # one directory/module per worker
|
|
424
|
+
│ ├── schemas/ # versioned runtime contracts and validators
|
|
425
|
+
│ ├── adapters/ # provider, git, repository, LLM, storage adapters
|
|
426
|
+
│ ├── registries/ # documentation and provider registration
|
|
427
|
+
│ ├── prompts/ # versioned worker prompt templates
|
|
428
|
+
│ ├── policy/ # scoring, budgets, planning and privacy policy
|
|
429
|
+
│ └── shared/ # ids, errors, event helpers, redaction
|
|
430
|
+
├── test/
|
|
431
|
+
│ ├── unit/
|
|
432
|
+
│ ├── contract/
|
|
433
|
+
│ ├── integration/
|
|
434
|
+
│ ├── fixtures/ # small known implementations and event logs
|
|
435
|
+
│ └── e2e/
|
|
436
|
+
├── docs/ # adapter authoring and architecture decision records
|
|
437
|
+
└── examples/ # mock provider integration, never product code
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Adapters depend inward on contracts; runtime and workers never import a provider
|
|
441
|
+
SDK. Prompt templates are data/versioned assets, so an evaluation can identify
|
|
442
|
+
which template generated a lesson.
|
|
443
|
+
|
|
444
|
+
## 15. Technology stack justification
|
|
445
|
+
|
|
446
|
+
Use TypeScript on Node.js for the core. It offers a broad agent integration
|
|
447
|
+
surface, native async streaming, excellent schema/test tooling, and distributable
|
|
448
|
+
single-package ergonomics. Use Zod (or an equivalent runtime validator) because
|
|
449
|
+
LLM and adapter boundaries need runtime—not only compile-time—validation. Use
|
|
450
|
+
a small event emitter plus an append-only storage interface rather than a
|
|
451
|
+
workflow framework for MVP; the state graph is compact and explicit.
|
|
452
|
+
|
|
453
|
+
Use Vitest for fast unit/contract tests and deterministic fake adapters. Use
|
|
454
|
+
JSON Lines as the default local event-log format: human-readable, appendable,
|
|
455
|
+
portable, and enough for MVP. Keep the LLM gateway interface provider-agnostic;
|
|
456
|
+
it accepts structured request/response schemas and supports injected test
|
|
457
|
+
fixtures. No database, vector store, queue, or web UI is justified in MVP.
|
|
458
|
+
|
|
459
|
+
## 16. Tradeoffs and risks
|
|
460
|
+
|
|
461
|
+
| Area | Recommended tradeoff | Risk and mitigation |
|
|
462
|
+
| --- | --- | --- |
|
|
463
|
+
| Recommendation timing | Show only after analysis, never auto-start | Extra latency; set a small analysis budget and permit a low-detail recommendation. |
|
|
464
|
+
| Confidence input | Ask explicitly before teaching | Friction; group units and offer skip/default. |
|
|
465
|
+
| Streaming | Stream typed milestones, not partial hidden reasoning | Provider rendering varies; retain a blocking collector for simple adapters. |
|
|
466
|
+
| Context | Progressive targeted reads | May miss a global convention; disclose evidence limits and request a bounded expansion. |
|
|
467
|
+
| LLM evaluation | LLM grades reasoning with structured rubric | Inconsistency; use deterministic schema checks, fixture evaluations, and conservative mastery language. |
|
|
468
|
+
| Docs | Optional official retrieval | Stale/unavailable network; version-pin sources when possible and graceful offline fallback. |
|
|
469
|
+
| Resume | Event-log replay/checkpoint | Event content can be sensitive; use caller-controlled local storage, encryption hooks, and redaction. |
|
|
470
|
+
| Provider support | Thin adapters | UX parity is not immediate; define a capability matrix and degrade to text prompts. |
|
|
471
|
+
| Telemetry | Local diagnostics, opt-in aggregate metrics | Privacy; default no source/answer export and publish the event schema. |
|
|
472
|
+
|
|
473
|
+
Security posture: treat repository content and retrieved documentation as
|
|
474
|
+
untrusted input; do not execute excerpts, follow embedded instructions, or
|
|
475
|
+
allow content to alter policy. Redact known secrets before an LLM boundary,
|
|
476
|
+
limit paths/providers, and preserve least-privilege adapter access.
|
|
477
|
+
|
|
478
|
+
## 17. Implementation roadmap (after approval)
|
|
479
|
+
|
|
480
|
+
1. Establish package, contracts, reducer/state machine, event log, fake adapters,
|
|
481
|
+
and contract tests.
|
|
482
|
+
2. Build minimal context collector using conversation/diff/changed-file metadata
|
|
483
|
+
and deterministic budget enforcement.
|
|
484
|
+
3. Add opportunity detection, concept extraction, and dependency planner with
|
|
485
|
+
fixture-driven evaluations.
|
|
486
|
+
4. Add confidence gate, teaching/quiz/evaluation loop, and summary builder.
|
|
487
|
+
5. Add documentation-provider registry plus offline fallback and citations.
|
|
488
|
+
6. Implement Codex and Claude Code adapters against the same public capability;
|
|
489
|
+
verify cancellation, resume, and degraded-mode behavior.
|
|
490
|
+
7. Run quality/security/accessibility review, publish contributor and adapter
|
|
491
|
+
documentation, and release an explicitly scoped MVP.
|
|
492
|
+
|
|
493
|
+
Each phase has a working vertical slice; do not build future memory, graph, or
|
|
494
|
+
analytics infrastructure in anticipation of later work.
|
|
495
|
+
|
|
496
|
+
## 18. Testing strategy
|
|
497
|
+
|
|
498
|
+
- Unit tests: reducers, legal transitions, scoring bounds, planner ordering,
|
|
499
|
+
budgets, redaction, and deterministic fallback policy.
|
|
500
|
+
- Contract tests: every worker input/output, provider adapter, documentation
|
|
501
|
+
provider, and event version validates at runtime.
|
|
502
|
+
- Fixture integration tests: small implementations such as OAuth middleware,
|
|
503
|
+
cache invalidation, async retries, and migrations; assert evidence grounding,
|
|
504
|
+
dependency order, and question relevance.
|
|
505
|
+
- Replay tests: event logs reproduce exactly one terminal result without
|
|
506
|
+
duplicate operations.
|
|
507
|
+
- LLM quality evaluations: rubric-score grounding, misconception quality,
|
|
508
|
+
distractor plausibility, calibration, and unsupported-claim rate. Version
|
|
509
|
+
prompt/model/policy inputs and use a held-out fixture set.
|
|
510
|
+
- Adversarial tests: malicious repository text, secrets, unavailable docs,
|
|
511
|
+
malformed LLM JSON, stale revisions, cancel during every state, and reconnect
|
|
512
|
+
after every event.
|
|
513
|
+
- Accessibility/UX tests: keyboard-only confidence and MCQ flow, concise
|
|
514
|
+
announcements for streaming milestones, and text-only provider fallback.
|
|
515
|
+
|
|
516
|
+
## 19. Extension points, deliberately deferred
|
|
517
|
+
|
|
518
|
+
Future long-term memory consumes completed `Summary` events through a separate
|
|
519
|
+
`LearnerProfileStore`; it must not alter the MVP session schema. Knowledge graphs
|
|
520
|
+
can consume `Concept` and `DependencyEdge` records. Spaced repetition can
|
|
521
|
+
subscribe to `Evaluation` and `Summary` events. Interview mode replaces the
|
|
522
|
+
quiz worker behind the same `AssessmentStrategy` interface. New agent support
|
|
523
|
+
implements `ProviderAdapter`; new documentation sources implement
|
|
524
|
+
`DocumentationProvider`.
|
|
525
|
+
|
|
526
|
+
No extension is pre-built beyond interfaces and event contracts. This preserves
|
|
527
|
+
the MVP's small surface while avoiding a refactor of its core data flow.
|
|
528
|
+
|
|
529
|
+
## 20. Approval gates
|
|
530
|
+
|
|
531
|
+
Implementation must wait for decisions on the following unresolved product
|
|
532
|
+
choices. The recommended defaults are intentionally visible rather than hidden:
|
|
533
|
+
|
|
534
|
+
1. **Recommendation UX:** should agents show an automatic post-task recommendation
|
|
535
|
+
when score thresholds are met, or only surface `/codecall` on manual invocation?
|
|
536
|
+
Recommendation: automatic, non-blocking card with Start/Skip.
|
|
537
|
+
2. **Confidence UX:** should confidence be asked once per session or per learning
|
|
538
|
+
unit? Recommendation: grouped per unit, with a “use a default” skip action.
|
|
539
|
+
3. **Repository consent:** may the collector read targeted unchanged files without
|
|
540
|
+
a second prompt, or must every expansion be explicitly approved? Recommendation:
|
|
541
|
+
permit bounded targeted reads and disclose them in the session; require consent
|
|
542
|
+
only for a larger repository slice.
|
|
543
|
+
4. **Documentation network policy:** is network retrieval enabled by default when
|
|
544
|
+
authoritative sources exist? Recommendation: enabled only by an explicit
|
|
545
|
+
privacy setting or provider-level consent; offline/model-only by default.
|
|
546
|
+
5. **Session storage:** should resumable event logs live locally by default, or
|
|
547
|
+
should MVP be memory-only? Recommendation: caller-owned local JSONL with a
|
|
548
|
+
memory-only option.
|
|
549
|
+
6. **Initial provider scope:** do you want Codex and Claude Code released together,
|
|
550
|
+
or should one adapter establish the reference UX first? Recommendation: core
|
|
551
|
+
plus one reference adapter first, then the second against contract tests.
|
|
552
|
+
7. **Mastery wording:** may the UI say “mastered,” or should it report a bounded
|
|
553
|
+
session estimate? Recommendation: “estimated session mastery” only.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gaurav
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|