@treeseed/dsh-chapters 0.2.1 → 0.2.2-dev.2
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/cordis.patch.yml +7 -0
- package/docs/backlog.md +1566 -0
- package/docs/contract.md +281 -0
- package/docs/development.md +122 -0
- package/docs/host-protected-head-ask.md +80 -0
- package/docs/project-state.md +266 -0
- package/docs/verify.md +12 -0
- package/lib/arrival.js +24 -0
- package/lib/arrival.js.map +1 -1
- package/lib/aux-message.d.ts +17 -0
- package/lib/aux-message.js +20 -0
- package/lib/aux-message.js.map +1 -0
- package/lib/client.js +536 -227
- package/lib/client.js.map +1 -1
- package/lib/commands.js +107 -1
- package/lib/commands.js.map +1 -1
- package/lib/continue-core.d.ts +6 -0
- package/lib/continue-core.js +18 -13
- package/lib/continue-core.js.map +1 -1
- package/lib/engine-core.d.ts +3 -0
- package/lib/engine-core.js +4 -3
- package/lib/engine-core.js.map +1 -1
- package/lib/engine.d.ts +9 -0
- package/lib/engine.js +66 -4
- package/lib/engine.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +199 -8
- package/lib/index.js.map +1 -1
- package/lib/injections.js +10 -0
- package/lib/injections.js.map +1 -1
- package/lib/prompt-loop.d.ts +73 -0
- package/lib/prompt-loop.js +141 -0
- package/lib/prompt-loop.js.map +1 -0
- package/lib/prompt-runner.d.ts +44 -0
- package/lib/prompt-runner.js +85 -0
- package/lib/prompt-runner.js.map +1 -0
- package/lib/prompt-state.d.ts +124 -0
- package/lib/prompt-state.js +96 -0
- package/lib/prompt-state.js.map +1 -0
- package/lib/prompt.d.ts +32 -2
- package/lib/prompt.js +31 -9
- package/lib/prompt.js.map +1 -1
- package/lib/registry.d.ts +7 -0
- package/lib/registry.js +2 -0
- package/lib/registry.js.map +1 -1
- package/lib/render.d.ts +22 -1
- package/lib/render.js +40 -7
- package/lib/render.js.map +1 -1
- package/lib/repair-run.d.ts +27 -0
- package/lib/repair-run.js +85 -2
- package/lib/repair-run.js.map +1 -1
- package/lib/rules.js +8 -0
- package/lib/rules.js.map +1 -1
- package/lib/save-core.js +4 -4
- package/lib/save-core.js.map +1 -1
- package/lib/store.js +11 -0
- package/lib/store.js.map +1 -1
- package/lib/tools.d.ts +3 -0
- package/lib/tools.js +17 -4
- package/lib/tools.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +20 -16
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the session's goal, so a suggestion can serve it (#113).
|
|
3
|
+
*
|
|
4
|
+
* The durable-log shape is measured, not assumed — from a live session's own `goal/change` events:
|
|
5
|
+
* { kind:'goal/change', version:1, operation:'create'|'resume'|'pause'|…,
|
|
6
|
+
* goal:{ id, revision, objective, phase:'active'|'paused'|…, maxGoalRounds } }
|
|
7
|
+
* and goal rounds themselves arrive as `user/message` with `source.kind:'goal'` carrying
|
|
8
|
+
* `{goalId, revision, round}`. So the goal is readable from the log with no service dependency, which is how
|
|
9
|
+
* this plugin works everywhere else (durable reads, never a guessed API).
|
|
10
|
+
*
|
|
11
|
+
* Why it matters: a suggested next step that ignores an active goal is noise. The maintainer's rule is that
|
|
12
|
+
* the two compose — the suggestion runs alongside the goal and the loop yields when the purpose ends.
|
|
13
|
+
*/
|
|
14
|
+
import type { SessionEventLike } from './types.ts';
|
|
15
|
+
export type GoalPhaseView = 'none' | 'active' | 'paused' | 'blocked' | 'complete';
|
|
16
|
+
export interface ActiveGoal {
|
|
17
|
+
id: string;
|
|
18
|
+
revision: number;
|
|
19
|
+
objective: string;
|
|
20
|
+
phase: GoalPhaseView;
|
|
21
|
+
maxGoalRounds: number | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The newest goal declaration in the events, or null when the session has no goal.
|
|
25
|
+
*
|
|
26
|
+
* A malformed or partial row is SKIPPED rather than thrown on: this is host-authored data crossing a plugin
|
|
27
|
+
* boundary, and one unexpected row must not take the bar (or the archive) down with it.
|
|
28
|
+
*
|
|
29
|
+
* The operation vocabulary is now established from the shipped types — `GoalOperation =
|
|
30
|
+
* 'create'|'edit'|'pause'|'resume'|'complete'|'block'|'clear'` (`dsh-goal/lib/types/domain.d.ts:12`) — so
|
|
31
|
+
* `clear` (which carries `cleared: GoalRef`, not `goal`) is the real terminal removal. `delete`/`remove` are
|
|
32
|
+
* still accepted defensively: when I first wrote this I could not see the type, and a reader should not have
|
|
33
|
+
* to trust that a host rename would not silently resurrect a finished goal.
|
|
34
|
+
*
|
|
35
|
+
* LIVE reads should prefer the host's own accessors over this fold — `ctx.get('goals').get(agent)` for a
|
|
36
|
+
* `GoalView` (which also carries `roundsStarted` and the process-local `activation`), or
|
|
37
|
+
* `ctx.sessionProjections.stateOf(session,'goal')` the way `tools.ts` already reads `agentPreset`. This
|
|
38
|
+
* function exists for the paths that have only the log: repair, distill, and tests.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readActiveGoal(events: readonly SessionEventLike[]): ActiveGoal | null;
|
|
41
|
+
/** Whether the autorun loop still has a purpose to serve: armed means run on, anything else means stand down. */
|
|
42
|
+
export declare function goalAuthorizesAutorun(goal: ActiveGoal | null): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The goal block folded into the suggestion input. Written as a constraint on the NEXT step, not a restated
|
|
45
|
+
* objective: the model already has the conversation, and what it cannot see is that a goal governs this one.
|
|
46
|
+
*/
|
|
47
|
+
export declare function goalDirectiveOf(goal: ActiveGoal | null): string;
|
|
48
|
+
/**
|
|
49
|
+
* The bar's durable facts, as stored on the session row (#113). `turnSeq` is the identity of an offer:
|
|
50
|
+
* it is the `turn/end` seq the suggestion was generated FOR, which is what makes "one generation per
|
|
51
|
+
* turn" idempotent across a re-delivered event, a restart, or a second pull by the client.
|
|
52
|
+
*
|
|
53
|
+
* Deliberately absent: `autorun` and `expanded`. Those are the client's process-local intent — the goal
|
|
54
|
+
* bar's `activation` in everything but name — and persisting them would let a loop resume itself across a
|
|
55
|
+
* restart, which is the property the host's goal driver explicitly does NOT have.
|
|
56
|
+
*/
|
|
57
|
+
export interface PromptSuggestionState {
|
|
58
|
+
status: 'off' | 'analyzing' | 'ready' | 'failed';
|
|
59
|
+
text: string;
|
|
60
|
+
turnSeq: number | null;
|
|
61
|
+
error: string;
|
|
62
|
+
at: string;
|
|
63
|
+
/** #113: what kind of step this is. `goal-edit` re-cuts the standing objective, which the host reserves for
|
|
64
|
+
* a human turn, so autorun must never act on it. Measured: `dsh-tool-goal`'s `requireDirectHuman` gates
|
|
65
|
+
* create/edit/pause/resume on `source.kind === 'user'` in the open turn. */
|
|
66
|
+
intent: 'worker-step' | 'goal-edit';
|
|
67
|
+
/** The goal `revision` this offer was generated against, or null when no goal was active. A revision bump
|
|
68
|
+
* invalidates an outstanding offer rather than pushing last cycle's directive into a re-cut objective. */
|
|
69
|
+
goalRevision: number | null;
|
|
70
|
+
}
|
|
71
|
+
export declare const noSuggestion: PromptSuggestionState;
|
|
72
|
+
/** What the loop needs to know about the goal RIGHT NOW, from the service (activation is process-local and
|
|
73
|
+
* is not in the log, so this is the only honest source). */
|
|
74
|
+
export interface GoalSignal {
|
|
75
|
+
phase: GoalPhaseView;
|
|
76
|
+
activation: 'armed' | 'disarmed';
|
|
77
|
+
revision: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Split the protocol prefix off a suggestion. `GOAL:` means "this step changes the objective" and the human
|
|
81
|
+
* must be the one to send it; anything else is worker execution and may auto-run.
|
|
82
|
+
*
|
|
83
|
+
* Deliberately a PREFIX rule on the model's own one-line answer rather than a second structured call: the
|
|
84
|
+
* suggestion surface already validates one bounded string, and a protocol the model can see in the rules
|
|
85
|
+
* (see `prompt.ts`) costs 5 characters of `promptMaxChars` instead of another auxiliary request.
|
|
86
|
+
*/
|
|
87
|
+
export declare function classifyOffer(raw: string): {
|
|
88
|
+
intent: 'worker-step' | 'goal-edit';
|
|
89
|
+
text: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Does the host goal driver intend to start the next turn itself? Measured rule (`dsh-goal-round-driver`):
|
|
93
|
+
* it queues a round on idle when `phase === 'active' && activation === 'armed'`. Two loops starting turns at
|
|
94
|
+
* one boundary is a race against the driver's own reservation fence, so when this says yes we yield.
|
|
95
|
+
*/
|
|
96
|
+
export declare function goalDriverOwnsTheTurn(goal: GoalSignal | null): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* What the Suggested Next Step bar can ask the server for (#113), and the single shape the command plane
|
|
99
|
+
* exposes to the client. Kept next to `PromptSuggestionState` rather than in the loop module because the bar
|
|
100
|
+
* and the row are the same contract — a client that can read it can render it.
|
|
101
|
+
*/
|
|
102
|
+
export interface PromptBarAccess {
|
|
103
|
+
read(sessionId: string): Promise<PromptSuggestionState & {
|
|
104
|
+
autorun: 'armed' | 'disarmed';
|
|
105
|
+
fired: number;
|
|
106
|
+
}>;
|
|
107
|
+
/** `displaced` is the answer to "who starts the next turn": true when arming this loop also disarmed the
|
|
108
|
+
* goal driver's continuation, so the human is told which engine they just opted into. */
|
|
109
|
+
setAutorun(sessionId: string, on: boolean): {
|
|
110
|
+
autorun: 'armed' | 'disarmed';
|
|
111
|
+
fired: number;
|
|
112
|
+
displaced: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** #113: the bar's Run. Submits the offer on screen as a HUMAN-authored user turn, through the same
|
|
115
|
+
* follow-up path autorun uses — one behavior for "run it", whether a keystroke or the loop came first. */
|
|
116
|
+
runNow(sessionId: string): Promise<{
|
|
117
|
+
ok: boolean;
|
|
118
|
+
text?: string;
|
|
119
|
+
reason?: string;
|
|
120
|
+
}>;
|
|
121
|
+
disarmHuman(sessionId: string): void;
|
|
122
|
+
setOff(sessionId: string): Promise<void>;
|
|
123
|
+
setOn(sessionId: string): Promise<void>;
|
|
124
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const isStr = (v) => typeof v === 'string' && v.length > 0;
|
|
2
|
+
/**
|
|
3
|
+
* The newest goal declaration in the events, or null when the session has no goal.
|
|
4
|
+
*
|
|
5
|
+
* A malformed or partial row is SKIPPED rather than thrown on: this is host-authored data crossing a plugin
|
|
6
|
+
* boundary, and one unexpected row must not take the bar (or the archive) down with it.
|
|
7
|
+
*
|
|
8
|
+
* The operation vocabulary is now established from the shipped types — `GoalOperation =
|
|
9
|
+
* 'create'|'edit'|'pause'|'resume'|'complete'|'block'|'clear'` (`dsh-goal/lib/types/domain.d.ts:12`) — so
|
|
10
|
+
* `clear` (which carries `cleared: GoalRef`, not `goal`) is the real terminal removal. `delete`/`remove` are
|
|
11
|
+
* still accepted defensively: when I first wrote this I could not see the type, and a reader should not have
|
|
12
|
+
* to trust that a host rename would not silently resurrect a finished goal.
|
|
13
|
+
*
|
|
14
|
+
* LIVE reads should prefer the host's own accessors over this fold — `ctx.get('goals').get(agent)` for a
|
|
15
|
+
* `GoalView` (which also carries `roundsStarted` and the process-local `activation`), or
|
|
16
|
+
* `ctx.sessionProjections.stateOf(session,'goal')` the way `tools.ts` already reads `agentPreset`. This
|
|
17
|
+
* function exists for the paths that have only the log: repair, distill, and tests.
|
|
18
|
+
*/
|
|
19
|
+
export function readActiveGoal(events) {
|
|
20
|
+
let current = null;
|
|
21
|
+
for (const ev of events) {
|
|
22
|
+
if (ev.type !== 'goal/change')
|
|
23
|
+
continue;
|
|
24
|
+
const data = (ev.data ?? {});
|
|
25
|
+
const operation = isStr(data.operation) ? data.operation : '';
|
|
26
|
+
if (operation === 'clear' || operation === 'delete' || operation === 'remove') {
|
|
27
|
+
current = null;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const goal = (data.goal ?? {});
|
|
31
|
+
if (!isStr(goal.id) || !isStr(goal.objective))
|
|
32
|
+
continue;
|
|
33
|
+
const rawPhase = isStr(goal.phase) ? goal.phase : 'active';
|
|
34
|
+
const phase = rawPhase === 'paused' ? 'paused'
|
|
35
|
+
: rawPhase === 'blocked' ? 'blocked'
|
|
36
|
+
: rawPhase === 'complete' ? 'complete'
|
|
37
|
+
: 'active';
|
|
38
|
+
const merged = {
|
|
39
|
+
id: goal.id,
|
|
40
|
+
revision: Number.isFinite(goal.revision) ? goal.revision : (current?.revision ?? 0),
|
|
41
|
+
objective: goal.objective,
|
|
42
|
+
// A later terminal phase must not be resurrected by an unrelated row: complete is sticky per id.
|
|
43
|
+
phase: current !== null && current.id === goal.id && current.phase === 'complete' ? 'complete' : phase,
|
|
44
|
+
maxGoalRounds: Number.isFinite(goal.maxGoalRounds) ? goal.maxGoalRounds : null,
|
|
45
|
+
};
|
|
46
|
+
current = operation === 'complete' ? { ...merged, phase: 'complete' } : merged;
|
|
47
|
+
}
|
|
48
|
+
return current === null || current.phase === 'complete' ? null : current;
|
|
49
|
+
}
|
|
50
|
+
/** Whether the autorun loop still has a purpose to serve: armed means run on, anything else means stand down. */
|
|
51
|
+
export function goalAuthorizesAutorun(goal) {
|
|
52
|
+
return goal !== null && goal.phase === 'active';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The goal block folded into the suggestion input. Written as a constraint on the NEXT step, not a restated
|
|
56
|
+
* objective: the model already has the conversation, and what it cannot see is that a goal governs this one.
|
|
57
|
+
*/
|
|
58
|
+
export function goalDirectiveOf(goal) {
|
|
59
|
+
if (goal === null)
|
|
60
|
+
return 'No goal is active for this session. Recommend the next step the work itself calls for.';
|
|
61
|
+
return [
|
|
62
|
+
`An ACTIVE GOAL governs this session (revision ${String(goal.revision)}): ${goal.objective.slice(0, 600)}`,
|
|
63
|
+
'The recommended next step MUST advance that goal — a step that merely continues current work does not count.',
|
|
64
|
+
'If the goal is already accomplished, recommend the step that closes it out (mark it complete) rather than another round.',
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
export const noSuggestion = { status: 'off', text: '', turnSeq: null, error: '', at: '', intent: 'worker-step', goalRevision: null };
|
|
68
|
+
/**
|
|
69
|
+
* Split the protocol prefix off a suggestion. `GOAL:` means "this step changes the objective" and the human
|
|
70
|
+
* must be the one to send it; anything else is worker execution and may auto-run.
|
|
71
|
+
*
|
|
72
|
+
* Deliberately a PREFIX rule on the model's own one-line answer rather than a second structured call: the
|
|
73
|
+
* suggestion surface already validates one bounded string, and a protocol the model can see in the rules
|
|
74
|
+
* (see `prompt.ts`) costs 5 characters of `promptMaxChars` instead of another auxiliary request.
|
|
75
|
+
*/
|
|
76
|
+
export function classifyOffer(raw) {
|
|
77
|
+
const t = raw.trim();
|
|
78
|
+
const m = /^GOAL\s*:\s*/i.exec(t);
|
|
79
|
+
if (m === null)
|
|
80
|
+
return { intent: 'worker-step', text: t };
|
|
81
|
+
const rest = t.slice(m[0].length).trim();
|
|
82
|
+
// `GOAL:` with nothing after it is not a re-cut; treat it as a worker step so an empty protocol never
|
|
83
|
+
// blocks the loop with a phantom "needs you" offer.
|
|
84
|
+
if (rest === '')
|
|
85
|
+
return { intent: 'worker-step', text: t };
|
|
86
|
+
return { intent: 'goal-edit', text: rest };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Does the host goal driver intend to start the next turn itself? Measured rule (`dsh-goal-round-driver`):
|
|
90
|
+
* it queues a round on idle when `phase === 'active' && activation === 'armed'`. Two loops starting turns at
|
|
91
|
+
* one boundary is a race against the driver's own reservation fence, so when this says yes we yield.
|
|
92
|
+
*/
|
|
93
|
+
export function goalDriverOwnsTheTurn(goal) {
|
|
94
|
+
return goal !== null && goal.phase === 'active' && goal.activation === 'armed';
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=prompt-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-state.js","sourceRoot":"","sources":["../src/prompt-state.ts"],"names":[],"mappings":"AAyBA,MAAM,KAAK,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;AAEhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAA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AAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AAU1G;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IACpB,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IACzD,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IACxC,sGAAsG;IACtG,oDAAoD;IACpD,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IAC1D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAuB;IAC3D,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO,CAAA;AAChF,CAAC"}
|
package/lib/prompt.d.ts
CHANGED
|
@@ -6,9 +6,32 @@ export interface PromptRoute {
|
|
|
6
6
|
provider: string;
|
|
7
7
|
model: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* An offer, or a refusal. `quiet: true` marks the refusals that are NOT news — "there is nothing to recommend
|
|
11
|
+
* yet" and "suggestions are off" — so a caller can tell silence from failure (#113: the first thing the
|
|
12
|
+
* feature did on a fresh thread was shout). Genuine failures (no route, assembly, the model call) leave
|
|
13
|
+
* `quiet` falsy so they stay visible.
|
|
14
|
+
*
|
|
15
|
+
* WHY THIS IS NOT WIRED INTO `/chapters-prompt suggest` yet: the composer ghost obtains its suggestion by
|
|
16
|
+
* EXECUTING that same command over the client remote (`src/client/prompt-ghost.ts:61-65`) and treats
|
|
17
|
+
* `kind === 'success'` with non-empty text as AN OFFER. So softening the command's `kind` would render
|
|
18
|
+
* "no suggestion — nothing to recommend yet" as ghost text: a new bug, worse than the one it fixes. The
|
|
19
|
+
* command result carries no payload slot for this distinction, and the ghost's own guard
|
|
20
|
+
* (`shouldShowGhost`) has nothing to key on. Fixing the silence properly needs one of: a structured field on
|
|
21
|
+
* the command result the client may read, the ghost calling the surface through its own seam instead of a
|
|
22
|
+
* human-facing command, or the refusal text being machine-tagged. Decided deliberately, not by prose-prefix
|
|
23
|
+
* matching — see #113.
|
|
24
|
+
*/
|
|
9
25
|
export interface PromptSuggestionResult {
|
|
10
26
|
ok: boolean;
|
|
11
|
-
text: string;
|
|
27
|
+
text: string; /** 'nothing to recommend' when quiet; otherwise what went wrong — the bar shows it (#61). */
|
|
28
|
+
quiet?: boolean;
|
|
29
|
+
reason?: string;
|
|
30
|
+
}
|
|
31
|
+
/** What the surface will and won't accept, for a caller that must REPORT it (the command block, #113). */
|
|
32
|
+
export interface PromptLimits {
|
|
33
|
+
maxChars: number;
|
|
34
|
+
contextChars: number;
|
|
12
35
|
}
|
|
13
36
|
export interface PromptConfig {
|
|
14
37
|
/** config default for the model; '' ⇒ off unless a stored override says otherwise. */
|
|
@@ -42,7 +65,8 @@ export interface PromptDeps {
|
|
|
42
65
|
export interface SuggestSession {
|
|
43
66
|
id: string;
|
|
44
67
|
title?: string | undefined;
|
|
45
|
-
events: SessionEventLike[];
|
|
68
|
+
events: SessionEventLike[]; /** #113: when a goal governs the session, the constraint on the next step — see `goalDirectiveOf`. Text, not a goal object: goal semantics stay in one module. */
|
|
69
|
+
goalDirective?: string | undefined;
|
|
46
70
|
}
|
|
47
71
|
/** The surface the host command and `/chapters-status` speak to. */
|
|
48
72
|
export interface PromptSurface {
|
|
@@ -53,6 +77,10 @@ export interface PromptSurface {
|
|
|
53
77
|
};
|
|
54
78
|
setModel(spec: string | null): Promise<void>;
|
|
55
79
|
suggest(session: SuggestSession): Promise<PromptSuggestionResult>;
|
|
80
|
+
/** #113: the Suggested Next Step bar's server-side access — the row plus the process-local loop flags. */
|
|
81
|
+
bar?: import('./prompt-state.ts').PromptBarAccess;
|
|
82
|
+
/** the configured caps, so an output can state the number it validated against */
|
|
83
|
+
limits(): PromptLimits;
|
|
56
84
|
/** One line for /chapters-status — ON names the model, OFF names the command. */
|
|
57
85
|
statusLine(): string;
|
|
58
86
|
}
|
|
@@ -83,6 +111,8 @@ export declare function tailFromEvents(events: SessionEventLike[]): {
|
|
|
83
111
|
text: string;
|
|
84
112
|
}[];
|
|
85
113
|
export interface SuggestFacts {
|
|
114
|
+
/** #113: the active goal's constraint on the next step, already worded. Absent ⇒ no goal block. */
|
|
115
|
+
goalDirective?: string | undefined;
|
|
86
116
|
title?: string | undefined;
|
|
87
117
|
chapters: {
|
|
88
118
|
number: number;
|
package/lib/prompt.js
CHANGED
|
@@ -93,11 +93,17 @@ export function buildSuggestInput(facts, capChars, maxChars) {
|
|
|
93
93
|
const perMessage = (t) => (t.length > msgCap ? `${t.slice(0, msgCap - 1)}…` : t);
|
|
94
94
|
const render = (announce) => {
|
|
95
95
|
const head = `You are the second reader of a DSH session — a model that DEFINES the next step and never executes it.`;
|
|
96
|
-
const rules = `Write the ONE next prompt the human should send. A single imperative request; plain text; at most ${maxChars} characters; no preamble, no quotes, no markdown; it must follow from the latest state and propose nothing already done. Reply with ONLY that prompt.`;
|
|
96
|
+
const rules = `Write the ONE next prompt the human should send. A single imperative request; plain text; at most ${maxChars} characters; no preamble, no quotes, no markdown; it must follow from the latest state and propose nothing already done. Reply with ONLY that prompt. If it changes the standing objective, prefix it with GOAL: (the human sends those; autorun will not). Do not use the prefix for an ordinary next step.`;
|
|
97
97
|
const parts = [
|
|
98
98
|
head,
|
|
99
99
|
'',
|
|
100
100
|
`## Session${facts.title !== undefined && facts.title !== '' ? `: ${facts.title}` : ''}`,
|
|
101
|
+
// #113: the goal is stated BEFORE the history, because it is the thing that decides whether a candidate
|
|
102
|
+
// next step counts as progress. A suggestion that ignores an active goal is noise, and the maintainer's
|
|
103
|
+
// rule is that the two compose — so the constraint is not a footnote after the tail.
|
|
104
|
+
...(facts.goalDirective !== undefined && facts.goalDirective !== ''
|
|
105
|
+
? ['', facts.goalDirective, '']
|
|
106
|
+
: []),
|
|
101
107
|
'',
|
|
102
108
|
chapters.length > 0 ? '## Where it has been (chapters)' : '## Where it has been (no chapters yet)',
|
|
103
109
|
...chapters.map((c) => `${c.number}. ${c.title} — ${c.summary}`),
|
|
@@ -140,7 +146,14 @@ export function buildSuggestInput(facts, capChars, maxChars) {
|
|
|
140
146
|
droppedTail += 1;
|
|
141
147
|
continue;
|
|
142
148
|
}
|
|
143
|
-
|
|
149
|
+
// Every compressible part is gone and the input is STILL over cap: the fixed frame (head + rules +
|
|
150
|
+
// section scaffolding) alone exceeds `promptContextChars`. That was previously returned in silence,
|
|
151
|
+
// which is the #61 class exactly — the code knows, and says nothing. It cannot be truncated (invariant:
|
|
152
|
+
// refuse or announce, never clip), so it announces what happened and how to fix it. Surfaced by my own
|
|
153
|
+
// added rules text, which is how I found it: a longer frame made a tight fixture impossible to fit.
|
|
154
|
+
return input.length > capChars
|
|
155
|
+
? `${input}\n(frame alone exceeds the ${String(capChars)}-char budget by ${String(input.length - capChars)} chars — raise promptContextChars; nothing was truncated)`
|
|
156
|
+
: input;
|
|
144
157
|
}
|
|
145
158
|
}
|
|
146
159
|
/**
|
|
@@ -171,7 +184,7 @@ export function validateSuggestion(raw, maxChars) {
|
|
|
171
184
|
export function createPromptSurface(deps) {
|
|
172
185
|
const cache = new Map();
|
|
173
186
|
const inflight = new Map();
|
|
174
|
-
const refuse = (reason) => ({ ok: false, text: reason });
|
|
187
|
+
const refuse = (reason, quiet = false) => ({ ok: false, text: reason, ...(quiet ? { quiet: true } : {}) });
|
|
175
188
|
const effective = () => effectivePromptSpec(deps.getSetting(PROMPT_SETTING_KEY), deps.config.model);
|
|
176
189
|
const run = async (session, seq) => {
|
|
177
190
|
const { spec } = effective();
|
|
@@ -222,24 +235,33 @@ export function createPromptSurface(deps) {
|
|
|
222
235
|
async suggest(session) {
|
|
223
236
|
const { spec } = effective();
|
|
224
237
|
if (spec === '')
|
|
225
|
-
return refuse('prompt suggestions are off — enable with /chapters-prompt model <provider/model>');
|
|
238
|
+
return refuse('prompt suggestions are off — enable with /chapters-prompt model <provider/model>', true);
|
|
226
239
|
const events = session.events;
|
|
227
240
|
if (events.length === 0)
|
|
228
|
-
return refuse('nothing to recommend yet — the session has no surface events');
|
|
229
|
-
|
|
241
|
+
return refuse('nothing to recommend yet — the session has no surface events', true);
|
|
242
|
+
// #113: the cache key is the COMPLETED TURN, not the last surface event. A turn is many events — every
|
|
243
|
+
// step appends one — so an event-scoped key missed on each step and asked the model again, which is how
|
|
244
|
+
// one turn produced three different suggestions for the maintainer. Inside a turn the human sees one
|
|
245
|
+
// stable offer; a new turn is a new question.
|
|
246
|
+
let turnSeq = -1;
|
|
247
|
+
for (const ev of events) {
|
|
248
|
+
if (ev.type === 'turn/end' && ev.seq > turnSeq)
|
|
249
|
+
turnSeq = ev.seq;
|
|
250
|
+
}
|
|
230
251
|
const tail = tailFromEvents(events);
|
|
231
252
|
if (!tail.some((m) => m.role === 'assistant'))
|
|
232
|
-
return refuse('nothing to recommend yet — no completed assistant turn');
|
|
253
|
+
return refuse('nothing to recommend yet — no completed assistant turn', true);
|
|
233
254
|
const fresh = cache.get(session.id);
|
|
234
|
-
if (fresh !== undefined && fresh.seq ===
|
|
255
|
+
if (fresh !== undefined && fresh.seq === turnSeq)
|
|
235
256
|
return { ok: true, text: fresh.text };
|
|
236
257
|
const pending = inflight.get(session.id);
|
|
237
258
|
if (pending !== undefined)
|
|
238
259
|
return await pending;
|
|
239
|
-
const job = run(session,
|
|
260
|
+
const job = run(session, turnSeq).finally(() => { inflight.delete(session.id); });
|
|
240
261
|
inflight.set(session.id, job);
|
|
241
262
|
return await job;
|
|
242
263
|
},
|
|
264
|
+
limits: () => ({ maxChars: deps.config.maxChars, contextChars: deps.config.contextChars }),
|
|
243
265
|
statusLine() {
|
|
244
266
|
const { spec, source } = effective();
|
|
245
267
|
if (spec === '')
|
package/lib/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAA;AAGlE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAA;AA6ChD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA2B,EAAE,WAAmB;IAClF,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;IAC9E,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;IAC5B,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,YAAgC;IAC/E,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAA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CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;AACtH,CAAC"}
|
package/lib/registry.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { ChapterRecord } from './archive.ts';
|
|
18
18
|
import type { CollectionSignature } from './signature.ts';
|
|
19
|
+
import { type PromptSuggestionState } from './prompt-state.ts';
|
|
19
20
|
export interface SessionState {
|
|
20
21
|
/** Registry-level parent, set at continuation commit. null until linked. */
|
|
21
22
|
parentSession: string | null;
|
|
@@ -42,6 +43,12 @@ export interface SessionState {
|
|
|
42
43
|
rev?: number | undefined;
|
|
43
44
|
/** attemptKey -> numbers, so an idempotent retry reuses rather than duplicates. */
|
|
44
45
|
reservations: Record<string, number[]>;
|
|
46
|
+
/**
|
|
47
|
+
* #113: what the Suggested Next Step bar last offered, and for which turn. `turnSeq` is the identity of
|
|
48
|
+
* an offer — the one-generation-per-turn key — and the pair (`status`, `turnSeq`) is what lets a re-read
|
|
49
|
+
* after a restart say "there is nothing pending" instead of firing a second model call for a finished turn.
|
|
50
|
+
*/
|
|
51
|
+
promptSuggestion: PromptSuggestionState;
|
|
45
52
|
/**
|
|
46
53
|
* compactionId -> the plan summarize() committed to: the TOC text already
|
|
47
54
|
* cited `path`, so finalize (possibly after a crash and process restart)
|
package/lib/registry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { noSuggestion } from "./prompt-state.js";
|
|
1
2
|
export const freshSession = (sessionId) => ({
|
|
2
3
|
rev: 0,
|
|
3
4
|
parentSession: null,
|
|
@@ -7,6 +8,7 @@ export const freshSession = (sessionId) => ({
|
|
|
7
8
|
collections: [],
|
|
8
9
|
chapters: [],
|
|
9
10
|
reservations: {},
|
|
11
|
+
promptSuggestion: noSuggestion,
|
|
10
12
|
plans: {},
|
|
11
13
|
finalized: {},
|
|
12
14
|
});
|
package/lib/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAA8B,MAAM,mBAAmB,CAAA;AAuD5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAgB,EAAE,CAAC,CAAC;IAChE,GAAG,EAAE,CAAC;IACN,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,SAAS;IACtB,iBAAiB,EAAE,CAAC;IACpB,cAAc,EAAE,CAAC;IACjB,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,EAAE;IAChB,gBAAgB,EAAE,YAAY;IAC9B,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;CACd,CAAC,CAAA;AAgBF,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAC1B,KAAmB,EACnB,YAAoB,EACpB,IAAgG;IAEhG,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,CAAA;AACtE,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,KAAmB,EAAE,YAAoB,EAAE,OAA0B;IACjG,IAAI,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IAC7D,OAAO,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,EAAE,CAAA;AACtF,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,YAAoB,EAAW,EAAE,CAChF,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,SAAS,CAAA;AA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GED
|
@@ -34,8 +34,12 @@ export declare function oversizeRanges(rendered: readonly {
|
|
|
34
34
|
range: ChapterRange;
|
|
35
35
|
stats: {
|
|
36
36
|
estimatedTokens: number;
|
|
37
|
+
events?: number | undefined;
|
|
37
38
|
};
|
|
38
|
-
}[], chapterTokenTarget: number, oversizeFactor: number):
|
|
39
|
+
}[], chapterTokenTarget: number, oversizeFactor: number): {
|
|
40
|
+
errors: string[];
|
|
41
|
+
indivisible: string[];
|
|
42
|
+
};
|
|
39
43
|
/**
|
|
40
44
|
* The capped public form (#61). `chapters_segment` once emitted 49,932 characters of its OWN output while
|
|
41
45
|
* also reporting `(Omitted 275266 bytes …)` — ≈81K est tokens into a 32K-class window, asking a small
|
|
@@ -69,6 +73,23 @@ codegraphSymbols?: readonly string[]): RenderedChapter;
|
|
|
69
73
|
* The cumulative index that replaces compacted history. Built from registry records, never from an LLM —
|
|
70
74
|
* which is the entire latency argument: no summarization call, no tokens, no paraphrase.
|
|
71
75
|
*/
|
|
76
|
+
/** One line of a checkpoint notice's chapter index. */
|
|
77
|
+
export interface NoticeBullet {
|
|
78
|
+
path: string;
|
|
79
|
+
title: string;
|
|
80
|
+
summary: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The chapter index inside a continuation notice, capped at `cap` lines (0 = list everything).
|
|
84
|
+
*
|
|
85
|
+
* The cap is the difference between a notice whose size tracks history and one that settles. Each line costs
|
|
86
|
+
* ~120 characters, so an uncapped index moves the surface across the compaction trigger depending on how many
|
|
87
|
+
* chapters a run happened to write — which makes a leg parked on that boundary undistillable as a tape (measured
|
|
88
|
+
* on `heavy`: identical served bytes, boundary one assistant/tool round apart between two runs). Past the cap the
|
|
89
|
+
* text is byte-identical, and the omission is STATED rather than silent, because a model that cannot see the
|
|
90
|
+
* list must still know to search for it.
|
|
91
|
+
*/
|
|
92
|
+
export declare function noticeIndexSection(entries: readonly NoticeBullet[], cap: number): string;
|
|
72
93
|
export declare function renderIndex(entries: readonly {
|
|
73
94
|
path: string;
|
|
74
95
|
title: string;
|
package/lib/render.js
CHANGED
|
@@ -113,11 +113,32 @@ archiveFloor = 0) {
|
|
|
113
113
|
*/
|
|
114
114
|
export function oversizeRanges(rendered, chapterTokenTarget, oversizeFactor) {
|
|
115
115
|
const ceiling = Math.floor(chapterTokenTarget * oversizeFactor);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
const errors = [];
|
|
117
|
+
const indivisible = [];
|
|
118
|
+
for (const r of rendered) {
|
|
119
|
+
if (r.stats.estimatedTokens <= ceiling)
|
|
120
|
+
continue;
|
|
121
|
+
// #117: the escape valve. A range holding MORE THAN ONE event can be split, so exceeding the ceiling is
|
|
122
|
+
// the caller's mistake and stays a refusal. A range holding exactly ONE event cannot be reduced by any
|
|
123
|
+
// boundary choice — the event is the atom — and refusing it means a long session becomes permanently
|
|
124
|
+
// un-compactable. Measured, not theorised: this session's `chapters_continue` was refused four times
|
|
125
|
+
// because one `command/done` event rendered 77,903 est tokens. Clipping remains forbidden, so the honest
|
|
126
|
+
// options were "archive it whole" or "never archive this session again".
|
|
127
|
+
//
|
|
128
|
+
// The result is a loud, counted warning rather than silence (#61): the chapter carries one event larger
|
|
129
|
+
// than the window it exists for, and a reader must be told that `read` must go back to it in slices.
|
|
130
|
+
if (r.stats.events === 1) {
|
|
131
|
+
indivisible.push(`chapter "${r.range.title}" is ONE indivisible event (seq ${String(r.range.startSeq)}) at `
|
|
132
|
+
+ `${String(r.stats.estimatedTokens)} est tokens, over the hard oversize ceiling ${String(ceiling)} `
|
|
133
|
+
+ '(= chapterTokenTarget ' + String(chapterTokenTarget) + ' × ' + String(oversizeFactor) + ') — archived whole, '
|
|
134
|
+
+ 'because clipping is forbidden and no split can shrink a single event; reload it with read offset/limit');
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
errors.push(`"${r.range.title}" (seqs ${String(r.range.startSeq)}-${String(r.range.endSeq)}) rendered ${String(r.stats.estimatedTokens)} est tokens, `
|
|
138
|
+
+ `over the hard oversize ceiling ${String(ceiling)} (= chapterTokenTarget ${String(chapterTokenTarget)} × ${String(oversizeFactor)}) `
|
|
139
|
+
+ '— split at the next boundary; clipping is forbidden');
|
|
140
|
+
}
|
|
141
|
+
return { errors, indivisible };
|
|
121
142
|
}
|
|
122
143
|
/** Enumerate tool results in a range so the model can decide keep/defer against real sizes. */
|
|
123
144
|
/** Every oversized tool result in a range, ranked by size DESCENDING (dedupe keeps the last copy). */
|
|
@@ -486,9 +507,21 @@ codegraphSymbols) {
|
|
|
486
507
|
};
|
|
487
508
|
}
|
|
488
509
|
/**
|
|
489
|
-
* The
|
|
490
|
-
*
|
|
510
|
+
* The chapter index inside a continuation notice, capped at `cap` lines (0 = list everything).
|
|
511
|
+
*
|
|
512
|
+
* The cap is the difference between a notice whose size tracks history and one that settles. Each line costs
|
|
513
|
+
* ~120 characters, so an uncapped index moves the surface across the compaction trigger depending on how many
|
|
514
|
+
* chapters a run happened to write — which makes a leg parked on that boundary undistillable as a tape (measured
|
|
515
|
+
* on `heavy`: identical served bytes, boundary one assistant/tool round apart between two runs). Past the cap the
|
|
516
|
+
* text is byte-identical, and the omission is STATED rather than silent, because a model that cannot see the
|
|
517
|
+
* list must still know to search for it.
|
|
491
518
|
*/
|
|
519
|
+
export function noticeIndexSection(entries, cap) {
|
|
520
|
+
if (cap <= 0 || entries.length <= cap)
|
|
521
|
+
return renderIndex(entries);
|
|
522
|
+
return renderIndex(entries.slice(0, cap))
|
|
523
|
+
+ '\n… and older chapters are not listed here — use chapters_search to reach them.';
|
|
524
|
+
}
|
|
492
525
|
export function renderIndex(entries) {
|
|
493
526
|
return entries
|
|
494
527
|
.map((e, i) => `${i + 1}. [${e.title}](${e.path}) — ${e.summary}`)
|