@hobin/developer 0.1.9 → 0.1.11
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 +5 -1
- package/REFERENCE_ROUTING.md +1 -1
- package/extensions/compaction-language.ts +303 -0
- package/extensions/developer.ts +235 -8
- package/extensions/references/behavior-preserving-structural-change.md +10 -2
- package/extensions/skills.ts +6 -2
- package/extensions/state.ts +136 -34
- package/extensions/tui.ts +5 -0
- package/package.json +1 -1
- package/skills/model/SKILL.md +6 -2
- package/skills/model/references/problem-modeling.md +13 -3
- package/skills/sketch/SKILL.md +11 -3
- package/skills/sketch/reference-policy.json +13 -3
- package/skills/sketch/references/evidence-preserving-boundaries.md +200 -0
- package/skills/verify/SKILL.md +5 -2
- package/skills/verify/references/verifier-selection-and-pass-but-wrong.md +12 -1
package/README.md
CHANGED
|
@@ -84,7 +84,10 @@ details but are actually product, model, boundary, or evidence questions.
|
|
|
84
84
|
| Branches lose rationale | Evidence replays with its branch |
|
|
85
85
|
|
|
86
86
|
Developer coordinates judgment; Pi still reads, edits, runs, and tests the
|
|
87
|
-
product with its normal tools.
|
|
87
|
+
product with its normal tools. Across those judgments, an unchecked assertion,
|
|
88
|
+
cast, non-null claim, or typed decode is never treated as evidence that a domain
|
|
89
|
+
invariant holds: broader input must cross an owned parser or smart-constructor
|
|
90
|
+
boundary whose success returns the refined value.
|
|
88
91
|
|
|
89
92
|
## How it works
|
|
90
93
|
|
|
@@ -118,6 +121,7 @@ and the plausible judgment routes add no useful information.
|
|
|
118
121
|
| Clarify a feature | Separate meaning, constraints, examples, and blockers |
|
|
119
122
|
| Model behavior | Enumerate cases, contracts, transitions, and guarantees |
|
|
120
123
|
| Shape code | Expose data, interfaces, collaboration, state, and checks |
|
|
124
|
+
| Refine input safely | Turn broader input into invariant-carrying domain values before dependent effects |
|
|
121
125
|
| Inspect a design | Identify structural movement and model-code mismatch |
|
|
122
126
|
| Review an abstraction | Keep, revise, split, reject, or defer the candidate |
|
|
123
127
|
| Time a refactor | Separate behavior work and judge the cost of delay |
|
package/REFERENCE_ROUTING.md
CHANGED
|
@@ -200,7 +200,7 @@ separation behavior, and pass-but-wrong cases.
|
|
|
200
200
|
| --- | --- | --- |
|
|
201
201
|
| `abstraction-review` | `candidate-contract-review`, `failed-candidate-check`, `candidate-calibration` | review, failure localization, or promise-based calibration; no shadow construction |
|
|
202
202
|
| `model` | `condition-space`, `contract-replacement`, `relational-constraints`, `temporal-behavior`, `proof-obligation`, `solver-result-boundary`, `logic-query-semantics`, `planning-model` | one model artifact per uncertainty and stop condition |
|
|
203
|
-
| `sketch` | `data-driven-design`, `data-shape-template`, `composition-by-wishes`, `earned-abstraction`, `generative-recursion`, `accumulator-invariant`, `design-levels`, `representation-barrier`, `closure-interface`, `process-resources`, `state-history-order`, `generic-dispatch`, `meaning-preserving-conversion`, `language-semantics`, `runtime-compilation`, `responsibility-collaboration`, `variation-role`, `type-transition`, `selection-creation` | one implementable design question per route, with route-local common kernels only where required |
|
|
203
|
+
| `sketch` | `data-driven-design`, `data-shape-template`, `composition-by-wishes`, `earned-abstraction`, `generative-recursion`, `accumulator-invariant`, `evidence-preserving-boundary`, `design-levels`, `representation-barrier`, `closure-interface`, `process-resources`, `state-history-order`, `generic-dispatch`, `meaning-preserving-conversion`, `language-semantics`, `runtime-compilation`, `responsibility-collaboration`, `variation-role`, `type-transition`, `selection-creation` | one implementable design question per route, with route-local common kernels only where required |
|
|
204
204
|
| `signal` | `behavior-preserving-movement` | singleton |
|
|
205
205
|
| `schedule` | `structural-timing-tradeoff` | singleton |
|
|
206
206
|
| `naming-judgment` | `domain-sense-boundary` | singleton |
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
export const COMPACTION_LANGUAGE_PROTOCOL =
|
|
2
|
+
"developer.compaction-language/v1" as const;
|
|
3
|
+
export const COMPACTION_LANGUAGE_ENTRY =
|
|
4
|
+
"developer.compaction-language" as const;
|
|
5
|
+
export const COMPACTION_LANGUAGE_MESSAGE =
|
|
6
|
+
"developer.compaction-language-continuity" as const;
|
|
7
|
+
|
|
8
|
+
export type LanguageTag = string;
|
|
9
|
+
|
|
10
|
+
export interface LanguageObserved {
|
|
11
|
+
protocol: typeof COMPACTION_LANGUAGE_PROTOCOL;
|
|
12
|
+
kind: "language-observed";
|
|
13
|
+
tag: LanguageTag;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ContinuityPending {
|
|
17
|
+
protocol: typeof COMPACTION_LANGUAGE_PROTOCOL;
|
|
18
|
+
kind: "continuity-pending";
|
|
19
|
+
compactionId: string;
|
|
20
|
+
tag: LanguageTag;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ContinuityConsumed {
|
|
24
|
+
protocol: typeof COMPACTION_LANGUAGE_PROTOCOL;
|
|
25
|
+
kind: "continuity-consumed";
|
|
26
|
+
compactionId: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type CompactionLanguageEvent =
|
|
30
|
+
| LanguageObserved
|
|
31
|
+
| ContinuityPending
|
|
32
|
+
| ContinuityConsumed;
|
|
33
|
+
|
|
34
|
+
export interface PendingContinuity {
|
|
35
|
+
compactionId: string;
|
|
36
|
+
tag: LanguageTag;
|
|
37
|
+
injected: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CompactionLanguageState {
|
|
41
|
+
language?: LanguageTag;
|
|
42
|
+
pending?: PendingContinuity;
|
|
43
|
+
consumedCompactionIds: ReadonlySet<string>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ContinuityContextMessage {
|
|
47
|
+
role: "custom";
|
|
48
|
+
customType: typeof COMPACTION_LANGUAGE_MESSAGE;
|
|
49
|
+
content: Array<{ type: "text"; text: string }>;
|
|
50
|
+
display: false;
|
|
51
|
+
details: {
|
|
52
|
+
protocol: typeof COMPACTION_LANGUAGE_PROTOCOL;
|
|
53
|
+
compactionId: string;
|
|
54
|
+
tag: LanguageTag;
|
|
55
|
+
};
|
|
56
|
+
timestamp: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface BranchEntryLike {
|
|
60
|
+
type?: string;
|
|
61
|
+
customType?: string;
|
|
62
|
+
data?: unknown;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const KOREAN_SCRIPT = /[\u3131-\u318e\uac00-\ud7a3]/u;
|
|
66
|
+
const ENGLISH_WORD = /[A-Za-z]+(?:'[A-Za-z]+)?/g;
|
|
67
|
+
const COMMAND_ONLY =
|
|
68
|
+
/^(?:npm|pnpm|yarn|node|npx|git|rg|grep|find|cd|ls|cat|sed|bash)\b(?:\s+[-\w./:@]+)*$/u;
|
|
69
|
+
const WEAK_ENGLISH_INPUTS = new Set([
|
|
70
|
+
"continue",
|
|
71
|
+
"done",
|
|
72
|
+
"go on",
|
|
73
|
+
"next",
|
|
74
|
+
"no",
|
|
75
|
+
"ok",
|
|
76
|
+
"okay",
|
|
77
|
+
"proceed",
|
|
78
|
+
"retry",
|
|
79
|
+
"yes",
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
83
|
+
return typeof value === "object" && value !== null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function proseCandidate(text: string): string {
|
|
87
|
+
return text
|
|
88
|
+
.replace(/```[\s\S]*?```/gu, " ")
|
|
89
|
+
.replace(/`[^`\n]*`/gu, " ")
|
|
90
|
+
.replace(/https?:\/\/\S+/gu, " ")
|
|
91
|
+
.replace(/(?:^|\s)(?:\.{0,2}\/|\/)\S+/gu, " ")
|
|
92
|
+
.replace(/\b[\w.-]+\.[A-Za-z0-9]{1,8}\b/gu, " ")
|
|
93
|
+
.replace(/\b(?:route:\S+|[A-Za-z][A-Za-z0-9]*_[A-Za-z0-9_]+)\b/gu, " ")
|
|
94
|
+
.replace(/\s+/gu, " ")
|
|
95
|
+
.trim();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function canonicalLanguageTag(value: string): LanguageTag | undefined {
|
|
99
|
+
try {
|
|
100
|
+
return Intl.getCanonicalLocales(value.trim())[0];
|
|
101
|
+
} catch {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Conservatively observes direct user prose; weak input preserves prior state. */
|
|
107
|
+
export function detectStrongUserLanguage(
|
|
108
|
+
text: string,
|
|
109
|
+
source: string,
|
|
110
|
+
): LanguageTag | undefined {
|
|
111
|
+
if (source !== "interactive" && source !== "rpc") return undefined;
|
|
112
|
+
const normalized = text.trim();
|
|
113
|
+
if (!normalized) return undefined;
|
|
114
|
+
if (KOREAN_SCRIPT.test(normalized)) return "ko";
|
|
115
|
+
|
|
116
|
+
const lower = normalized.toLowerCase().replace(/\s+/gu, " ");
|
|
117
|
+
if (WEAK_ENGLISH_INPUTS.has(lower) || COMMAND_ONLY.test(normalized)) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
const words = proseCandidate(normalized).match(ENGLISH_WORD) ?? [];
|
|
121
|
+
const letterCount = words.reduce((count, word) => count + word.length, 0);
|
|
122
|
+
return words.length >= 2 && letterCount >= 8 ? "en" : undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function languageObserved(tag: LanguageTag): LanguageObserved {
|
|
126
|
+
const canonical = canonicalLanguageTag(tag);
|
|
127
|
+
if (!canonical) throw new Error(`Invalid language tag: ${tag}`);
|
|
128
|
+
return {
|
|
129
|
+
protocol: COMPACTION_LANGUAGE_PROTOCOL,
|
|
130
|
+
kind: "language-observed",
|
|
131
|
+
tag: canonical,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function continuityPending(
|
|
136
|
+
compactionId: string,
|
|
137
|
+
tag: LanguageTag,
|
|
138
|
+
): ContinuityPending {
|
|
139
|
+
const canonical = canonicalLanguageTag(tag);
|
|
140
|
+
if (!canonical) throw new Error(`Invalid language tag: ${tag}`);
|
|
141
|
+
if (!compactionId.trim()) throw new Error("Compaction ID must not be empty.");
|
|
142
|
+
return {
|
|
143
|
+
protocol: COMPACTION_LANGUAGE_PROTOCOL,
|
|
144
|
+
kind: "continuity-pending",
|
|
145
|
+
compactionId,
|
|
146
|
+
tag: canonical,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function continuityConsumed(compactionId: string): ContinuityConsumed {
|
|
151
|
+
if (!compactionId.trim()) throw new Error("Compaction ID must not be empty.");
|
|
152
|
+
return {
|
|
153
|
+
protocol: COMPACTION_LANGUAGE_PROTOCOL,
|
|
154
|
+
kind: "continuity-consumed",
|
|
155
|
+
compactionId,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function normalizeCompactionLanguageEvent(
|
|
160
|
+
value: unknown,
|
|
161
|
+
): CompactionLanguageEvent | undefined {
|
|
162
|
+
if (!isObject(value) || value.protocol !== COMPACTION_LANGUAGE_PROTOCOL) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
if (value.kind === "language-observed" && typeof value.tag === "string") {
|
|
166
|
+
const tag = canonicalLanguageTag(value.tag);
|
|
167
|
+
return tag ? languageObserved(tag) : undefined;
|
|
168
|
+
}
|
|
169
|
+
if (
|
|
170
|
+
value.kind === "continuity-pending" &&
|
|
171
|
+
typeof value.compactionId === "string" &&
|
|
172
|
+
value.compactionId.trim() &&
|
|
173
|
+
typeof value.tag === "string"
|
|
174
|
+
) {
|
|
175
|
+
const tag = canonicalLanguageTag(value.tag);
|
|
176
|
+
return tag ? continuityPending(value.compactionId, tag) : undefined;
|
|
177
|
+
}
|
|
178
|
+
if (
|
|
179
|
+
value.kind === "continuity-consumed" &&
|
|
180
|
+
typeof value.compactionId === "string" &&
|
|
181
|
+
value.compactionId.trim()
|
|
182
|
+
) {
|
|
183
|
+
return continuityConsumed(value.compactionId);
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function initialCompactionLanguageState(): CompactionLanguageState {
|
|
189
|
+
return { consumedCompactionIds: new Set() };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function applyCompactionLanguageEvent(
|
|
193
|
+
state: CompactionLanguageState,
|
|
194
|
+
event: CompactionLanguageEvent,
|
|
195
|
+
): CompactionLanguageState {
|
|
196
|
+
switch (event.kind) {
|
|
197
|
+
case "language-observed":
|
|
198
|
+
return {
|
|
199
|
+
...state,
|
|
200
|
+
language: event.tag,
|
|
201
|
+
pending: state.pending
|
|
202
|
+
? { ...state.pending, tag: event.tag }
|
|
203
|
+
: undefined,
|
|
204
|
+
};
|
|
205
|
+
case "continuity-pending":
|
|
206
|
+
if (
|
|
207
|
+
state.consumedCompactionIds.has(event.compactionId) ||
|
|
208
|
+
state.pending?.compactionId === event.compactionId
|
|
209
|
+
) {
|
|
210
|
+
return state;
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
...state,
|
|
214
|
+
pending: {
|
|
215
|
+
compactionId: event.compactionId,
|
|
216
|
+
tag: event.tag,
|
|
217
|
+
injected: false,
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
case "continuity-consumed": {
|
|
221
|
+
if (state.consumedCompactionIds.has(event.compactionId)) return state;
|
|
222
|
+
const consumedCompactionIds = new Set(state.consumedCompactionIds);
|
|
223
|
+
consumedCompactionIds.add(event.compactionId);
|
|
224
|
+
return {
|
|
225
|
+
...state,
|
|
226
|
+
pending:
|
|
227
|
+
state.pending?.compactionId === event.compactionId
|
|
228
|
+
? undefined
|
|
229
|
+
: state.pending,
|
|
230
|
+
consumedCompactionIds,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function markContinuityInjected(
|
|
237
|
+
state: CompactionLanguageState,
|
|
238
|
+
): CompactionLanguageState {
|
|
239
|
+
if (!state.pending || state.pending.injected) return state;
|
|
240
|
+
return { ...state, pending: { ...state.pending, injected: true } };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function settlementContinuityEvent(
|
|
244
|
+
state: CompactionLanguageState,
|
|
245
|
+
): ContinuityConsumed | undefined {
|
|
246
|
+
return state.pending?.injected
|
|
247
|
+
? continuityConsumed(state.pending.compactionId)
|
|
248
|
+
: undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function reconstructCompactionLanguage(
|
|
252
|
+
entries: ReadonlyArray<BranchEntryLike>,
|
|
253
|
+
): CompactionLanguageState {
|
|
254
|
+
return entries.reduce((state, entry) => {
|
|
255
|
+
if (
|
|
256
|
+
entry.type !== "custom" ||
|
|
257
|
+
entry.customType !== COMPACTION_LANGUAGE_ENTRY
|
|
258
|
+
) {
|
|
259
|
+
return state;
|
|
260
|
+
}
|
|
261
|
+
const event = normalizeCompactionLanguageEvent(entry.data);
|
|
262
|
+
return event ? applyCompactionLanguageEvent(state, event) : state;
|
|
263
|
+
}, initialCompactionLanguageState());
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function continuityMarkerText(tag: LanguageTag): string {
|
|
267
|
+
return `Post-compaction continuity: user-visible prose language=${tag}; explicit language requests win.`;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function continuityContextMessage(
|
|
271
|
+
pending: PendingContinuity,
|
|
272
|
+
timestamp = Date.now(),
|
|
273
|
+
): ContinuityContextMessage {
|
|
274
|
+
return {
|
|
275
|
+
role: "custom",
|
|
276
|
+
customType: COMPACTION_LANGUAGE_MESSAGE,
|
|
277
|
+
content: [{ type: "text", text: continuityMarkerText(pending.tag) }],
|
|
278
|
+
display: false,
|
|
279
|
+
details: {
|
|
280
|
+
protocol: COMPACTION_LANGUAGE_PROTOCOL,
|
|
281
|
+
compactionId: pending.compactionId,
|
|
282
|
+
tag: pending.tag,
|
|
283
|
+
},
|
|
284
|
+
timestamp,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function projectCompactionContinuity<T>(
|
|
289
|
+
messages: ReadonlyArray<T>,
|
|
290
|
+
state: CompactionLanguageState,
|
|
291
|
+
timestamp = Date.now(),
|
|
292
|
+
):
|
|
293
|
+
| {
|
|
294
|
+
messages: Array<T | ContinuityContextMessage>;
|
|
295
|
+
state: CompactionLanguageState;
|
|
296
|
+
}
|
|
297
|
+
| undefined {
|
|
298
|
+
if (!state.pending) return undefined;
|
|
299
|
+
return {
|
|
300
|
+
messages: [...messages, continuityContextMessage(state.pending, timestamp)],
|
|
301
|
+
state: markContinuityInjected(state),
|
|
302
|
+
};
|
|
303
|
+
}
|