@treeseed/dsh-chapters 0.1.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/LICENSE +14 -0
- package/README.md +644 -0
- package/cordis.patch.yml +88 -0
- package/docs/architecture.md +460 -0
- package/docs/contract.md +375 -0
- package/docs/development.md +437 -0
- package/docs/host-compaction-seam.md +117 -0
- package/docs/knowledge-repo.md +730 -0
- package/docs/provider.md +98 -0
- package/docs/verify.md +200 -0
- package/lib/archive.d.ts +88 -0
- package/lib/archive.js +114 -0
- package/lib/archive.js.map +1 -0
- package/lib/arrival.d.ts +23 -0
- package/lib/arrival.js +86 -0
- package/lib/arrival.js.map +1 -0
- package/lib/artifact-query.d.ts +53 -0
- package/lib/artifact-query.js +130 -0
- package/lib/artifact-query.js.map +1 -0
- package/lib/client.js +234 -0
- package/lib/client.js.map +1 -0
- package/lib/commands.d.ts +28 -0
- package/lib/commands.js +305 -0
- package/lib/commands.js.map +1 -0
- package/lib/compose.d.ts +30 -0
- package/lib/compose.js +131 -0
- package/lib/compose.js.map +1 -0
- package/lib/continue-core.d.ts +153 -0
- package/lib/continue-core.js +252 -0
- package/lib/continue-core.js.map +1 -0
- package/lib/engine-core.d.ts +219 -0
- package/lib/engine-core.js +405 -0
- package/lib/engine-core.js.map +1 -0
- package/lib/engine.d.ts +211 -0
- package/lib/engine.js +571 -0
- package/lib/engine.js.map +1 -0
- package/lib/enrich-queue.d.ts +66 -0
- package/lib/enrich-queue.js +100 -0
- package/lib/enrich-queue.js.map +1 -0
- package/lib/enrich-store.d.ts +31 -0
- package/lib/enrich-store.js +103 -0
- package/lib/enrich-store.js.map +1 -0
- package/lib/enrich-wire.d.ts +73 -0
- package/lib/enrich-wire.js +209 -0
- package/lib/enrich-wire.js.map +1 -0
- package/lib/enrich.d.ts +73 -0
- package/lib/enrich.js +150 -0
- package/lib/enrich.js.map +1 -0
- package/lib/gitops.d.ts +107 -0
- package/lib/gitops.js +539 -0
- package/lib/gitops.js.map +1 -0
- package/lib/index.d.ts +81 -0
- package/lib/index.js +305 -0
- package/lib/index.js.map +1 -0
- package/lib/indexing.d.ts +85 -0
- package/lib/indexing.js +212 -0
- package/lib/indexing.js.map +1 -0
- package/lib/injections.d.ts +66 -0
- package/lib/injections.js +83 -0
- package/lib/injections.js.map +1 -0
- package/lib/notice.d.ts +60 -0
- package/lib/notice.js +84 -0
- package/lib/notice.js.map +1 -0
- package/lib/provider.d.ts +44 -0
- package/lib/provider.js +66 -0
- package/lib/provider.js.map +1 -0
- package/lib/redact.d.ts +24 -0
- package/lib/redact.js +85 -0
- package/lib/redact.js.map +1 -0
- package/lib/registry.d.ts +120 -0
- package/lib/registry.js +130 -0
- package/lib/registry.js.map +1 -0
- package/lib/render.d.ts +40 -0
- package/lib/render.js +280 -0
- package/lib/render.js.map +1 -0
- package/lib/repo.d.ts +78 -0
- package/lib/repo.js +184 -0
- package/lib/repo.js.map +1 -0
- package/lib/rules-commands.d.ts +24 -0
- package/lib/rules-commands.js +138 -0
- package/lib/rules-commands.js.map +1 -0
- package/lib/rules.d.ts +90 -0
- package/lib/rules.js +185 -0
- package/lib/rules.js.map +1 -0
- package/lib/search.d.ts +48 -0
- package/lib/search.js +152 -0
- package/lib/search.js.map +1 -0
- package/lib/signature.d.ts +28 -0
- package/lib/signature.js +149 -0
- package/lib/signature.js.map +1 -0
- package/lib/store.d.ts +130 -0
- package/lib/store.js +235 -0
- package/lib/store.js.map +1 -0
- package/lib/sync.d.ts +183 -0
- package/lib/sync.js +719 -0
- package/lib/sync.js.map +1 -0
- package/lib/tools.d.ts +84 -0
- package/lib/tools.js +581 -0
- package/lib/tools.js.map +1 -0
- package/lib/treedx/client.d.ts +57 -0
- package/lib/treedx/client.js +82 -0
- package/lib/treedx/client.js.map +1 -0
- package/lib/treedx/provider.d.ts +39 -0
- package/lib/treedx/provider.js +479 -0
- package/lib/treedx/provider.js.map +1 -0
- package/lib/treedx/state.d.ts +27 -0
- package/lib/treedx/state.js +65 -0
- package/lib/treedx/state.js.map +1 -0
- package/lib/types.d.ts +100 -0
- package/lib/types.js +19 -0
- package/lib/types.js.map +1 -0
- package/lib/vocabulary.d.ts +41 -0
- package/lib/vocabulary.js +118 -0
- package/lib/vocabulary.js.map +1 -0
- package/package.json +132 -0
- package/presets/chapters/agent.cordis.yml +272 -0
- package/presets/chapters/preset.yml +3 -0
- package/presets/probe-roots/agent.cordis.yml +11 -0
- package/presets/probe-roots/preset.yml +3 -0
package/lib/commands.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side slash commands for the knowledge layer (knowledge-repo.md §5, §2).
|
|
3
|
+
* Both render as command flow nodes — verified to stay OUT of the model's
|
|
4
|
+
* context (record §7.2: in-session UX, zero context cost).
|
|
5
|
+
*
|
|
6
|
+
* /chapters-link show upstream + mirror status
|
|
7
|
+
* /chapters-link <local-path> bind a path upstream (no creds)
|
|
8
|
+
* /chapters-link <https-url> <token> bind a network git upstream
|
|
9
|
+
* /chapters-link treedx+<url>/<repo> <token> bind a TreeDX service upstream
|
|
10
|
+
* /chapters-status last sync result
|
|
11
|
+
* /chapters-enrich run | model … | report P2 enrichment surface (record §6.2)
|
|
12
|
+
*/
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { DEFAULT_CLONE_DIR, planStoreToRepo, projectForCwd, readSyncStatus, readToken, runSync, writeToken, } from "./sync.js";
|
|
16
|
+
import { isLocalUpstreamUrl, readOrigin, resolveLocalUpstreamPath } from "./gitops.js";
|
|
17
|
+
import { parseKnowledgeRemote, projectKeyForTarget, projectKeyFromRemote, resolveProject } from "./repo.js";
|
|
18
|
+
import { createTreeDxClient } from "./treedx/client.js";
|
|
19
|
+
import { resolveRepoId } from "./treedx/provider.js";
|
|
20
|
+
import { readState } from "./treedx/state.js";
|
|
21
|
+
import { selectProvider } from "./provider.js";
|
|
22
|
+
const cwdOf = (agent) => (agent?.session?.header?.cwd ?? process.cwd());
|
|
23
|
+
/** branch name (or short oid) the mirror's HEAD points at. */
|
|
24
|
+
function readMirrorHead(mirrorAbs) {
|
|
25
|
+
try {
|
|
26
|
+
const head = fs.readFileSync(path.join(mirrorAbs, '.git', 'HEAD'), 'utf8').trim();
|
|
27
|
+
const m = /^ref: refs\/heads\/(.+)$/.exec(head);
|
|
28
|
+
return m?.[1] ?? head.slice(0, 8);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** store files not yet present in the mirror (the honest pending-push view). */
|
|
35
|
+
function countPending(mirrorAbs, storeDir, projectKey) {
|
|
36
|
+
try {
|
|
37
|
+
return planStoreToRepo(storeDir, projectKey).filter((f) => !fs.existsSync(path.join(mirrorAbs, f.rel))).length;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function registerHostCommands(ctx, domain, config) {
|
|
44
|
+
const commands = ctx.get?.('commands');
|
|
45
|
+
const disposers = [];
|
|
46
|
+
if (commands?.register === undefined)
|
|
47
|
+
return () => { };
|
|
48
|
+
/**
|
|
49
|
+
* /chapters-link — the upstream configuration surface, three modes:
|
|
50
|
+
* (no args) show the current upstream + mirror state (git-status-like)
|
|
51
|
+
* <local-path> bind the pool to a directory upstream (bare repo created
|
|
52
|
+
* on demand; no credentials — §2.1's local upstreams)
|
|
53
|
+
* <url> <token> bind to an http(s) upstream; the token is REQUIRED unless
|
|
54
|
+
* the host is loopback, and is stored in the DSH home, 0600
|
|
55
|
+
*/
|
|
56
|
+
const linkCommand = {
|
|
57
|
+
name: 'chapters-link',
|
|
58
|
+
description: 'Show / set this project\u2019s knowledge upstream: /chapters-link [path | <https-url> <token> | treedx+<url>/<repo> <token>]',
|
|
59
|
+
input: { hint: '[path | <https-remote-url> <token> | treedx+<url>/<repo> <token>]' },
|
|
60
|
+
async handler(invocation) {
|
|
61
|
+
const parts = (invocation.rawInput ?? '').trim().split(/\s+/).filter((p) => p.length > 0);
|
|
62
|
+
const cwd = cwdOf(invocation.agent);
|
|
63
|
+
const table = domain.table('projects');
|
|
64
|
+
try {
|
|
65
|
+
// ---- mode 1: no args — the git-status-like view
|
|
66
|
+
if (parts.length === 0) {
|
|
67
|
+
const rec = projectForCwd(table.entries(), cwd);
|
|
68
|
+
if (rec === undefined) {
|
|
69
|
+
return { kind: 'success', text: 'Upstream: none — this workspace is knowledge-local (chapters, forks, signatures all work; nothing syncs).\nSet one: /chapters-link <path> or /chapters-link <https-url> <token>' };
|
|
70
|
+
}
|
|
71
|
+
const mirrorAbs = path.join(cwd, DEFAULT_CLONE_DIR);
|
|
72
|
+
const treedx = (rec.kind ?? 'git') === 'treedx';
|
|
73
|
+
const tstate = treedx ? readState(mirrorAbs) : null;
|
|
74
|
+
const head = treedx ? (tstate?.head !== null && tstate?.head !== undefined ? tstate.head.slice(0, 10) : null) : readMirrorHead(mirrorAbs);
|
|
75
|
+
const origin = treedx ? tstate?.origin ?? null : readOrigin(mirrorAbs);
|
|
76
|
+
const status = readSyncStatus(cwd, config.artifactStoreRoot);
|
|
77
|
+
const pending = countPending(mirrorAbs, path.join(cwd, config.artifactStoreRoot), rec.projectKey);
|
|
78
|
+
const hasToken = readToken(cwd, config.artifactStoreRoot, rec.projectKey) !== undefined;
|
|
79
|
+
const local = isLocalUpstreamUrl(rec.remote);
|
|
80
|
+
const lines = [
|
|
81
|
+
`Provider: ${rec.kind ?? 'git'}`,
|
|
82
|
+
`Upstream: ${rec.remote}`,
|
|
83
|
+
`Bound: ${rec.slug} · key ${rec.projectKey} · since ${rec.linkedAt}`,
|
|
84
|
+
`Mirror: ${fs.existsSync(mirrorAbs) ? DEFAULT_CLONE_DIR : '(not created yet)'}` +
|
|
85
|
+
(treedx ? ` head ${head ?? (tstate === null ? 'not cloned' : 'empty repo')}${tstate?.offline === true ? ' · OFFLINE (push deferred)' : ''}` : ` branch ${head ?? 'main'}`) +
|
|
86
|
+
(origin !== null && origin !== (treedx ? rec.remote : local ? resolveLocalUpstreamPath(rec.remote, cwd) : rec.remote) ? ` [origin drift: ${origin} — will rebuild]` : ''),
|
|
87
|
+
`Sync: ${status === null ? 'never run' : `${status.mode} @ ${status.at}`}${status !== null && !status.lastOk ? ` — ${status.detail}` : ''}`,
|
|
88
|
+
`Pending: ${pending} file(s) not yet mirrored${hasToken || local ? '' : ' ⚠ no credentials — /chapters-link ' + (treedx ? 'treedx+<url>/<repo> <token>' : '<url> <token>')}`,
|
|
89
|
+
`Harness: ${rec.harnessId}`,
|
|
90
|
+
];
|
|
91
|
+
return { kind: 'success', text: lines.join('\n') };
|
|
92
|
+
}
|
|
93
|
+
// ---- mode 2: local-path upstream
|
|
94
|
+
const target = parts[0];
|
|
95
|
+
if (!/^https?:\/\//.test(target) && (target.startsWith('/') || target === '~' || target.startsWith('~/') || target.startsWith('./') || target.startsWith('../') || /^file:\/\/\//.test(target))) {
|
|
96
|
+
const resolved = resolveLocalUpstreamPath(target, cwd);
|
|
97
|
+
const record = {
|
|
98
|
+
projectKey: projectKeyFromRemote(`file://${resolved}`),
|
|
99
|
+
slug: path.basename(resolved).replace(/\.git$/, ''),
|
|
100
|
+
remote: resolved,
|
|
101
|
+
harnessId: config.harnessId,
|
|
102
|
+
linkedAt: new Date().toISOString(),
|
|
103
|
+
cwd,
|
|
104
|
+
};
|
|
105
|
+
table.put(record.projectKey, record);
|
|
106
|
+
const sync = await syncNow(cwd, record, undefined);
|
|
107
|
+
return { kind: 'success', text: `Linked to local upstream ${resolved} (a bare pool repo is created there if absent; no credentials needed).\nKey: ${record.projectKey}\nSync: ${sync.mode} \u2014 ${sync.steps.join(' \u2192 ') || sync.detail}` };
|
|
108
|
+
}
|
|
109
|
+
// ---- mode 4: TreeDX service upstream (§15 amendment)
|
|
110
|
+
if (target.startsWith('treedx+')) {
|
|
111
|
+
const parsed = parseKnowledgeRemote(target); // throws on a malformed form — caught below
|
|
112
|
+
const token = parts[1];
|
|
113
|
+
if (token === undefined || token === '') {
|
|
114
|
+
return { kind: 'error', text: 'TreeDX always needs a bearer token: /chapters-link treedx+<url>/<repo> <token> (a local dev container: scripts/treedx-local.sh token mints one)' };
|
|
115
|
+
}
|
|
116
|
+
if (parsed.treedx === undefined)
|
|
117
|
+
return { kind: 'error', text: 'internal: treedx+ target did not parse to a service target' };
|
|
118
|
+
const client = createTreeDxClient({ baseUrl: parsed.treedx.baseUrl, token, fetchTimeoutMs: 15000 });
|
|
119
|
+
// Resolve-or-create the managed repository — linking is an explicit
|
|
120
|
+
// human act (§2.1), so creating the named pool is in scope here and
|
|
121
|
+
// ONLY here. 409 (exists) is a success path. One shared live-shaped
|
|
122
|
+
// catalog parser with the transport (repoCatalog/resolveRepoId) —
|
|
123
|
+
// the first live run broke precisely on parser drift.
|
|
124
|
+
let repoId = await resolveRepoId(client, parsed.treedx.repoName);
|
|
125
|
+
let resolveNote = '';
|
|
126
|
+
if (repoId === '') {
|
|
127
|
+
const created = await client.post('/api/v1/repos', {
|
|
128
|
+
repositoryName: parsed.treedx.repoName, source: { type: 'empty' }, placement: { mode: 'local' },
|
|
129
|
+
});
|
|
130
|
+
if (!created.ok && created.code !== 'conflict' && created.status !== 409) {
|
|
131
|
+
return { kind: 'error', text: `TreeDX repository '${parsed.treedx.repoName}' not found and create failed (${created.detail}) — check the URL/token or create it server-side.` };
|
|
132
|
+
}
|
|
133
|
+
resolveNote = '\nCreated the managed repository (born with refs/heads/main).';
|
|
134
|
+
repoId = await resolveRepoId(client, parsed.treedx.repoName);
|
|
135
|
+
}
|
|
136
|
+
const record = {
|
|
137
|
+
projectKey: projectKeyForTarget(parsed),
|
|
138
|
+
slug: parsed.treedx.repoName,
|
|
139
|
+
remote: target,
|
|
140
|
+
kind: 'treedx',
|
|
141
|
+
...(repoId !== '' ? { repoId } : {}),
|
|
142
|
+
harnessId: config.harnessId,
|
|
143
|
+
linkedAt: new Date().toISOString(),
|
|
144
|
+
cwd,
|
|
145
|
+
};
|
|
146
|
+
writeToken(record.projectKey, token);
|
|
147
|
+
table.put(record.projectKey, record);
|
|
148
|
+
const sync = await syncNow(cwd, record, token);
|
|
149
|
+
return {
|
|
150
|
+
kind: 'success',
|
|
151
|
+
text: `Linked to TreeDX ${parsed.treedx.baseUrl} repo '${parsed.treedx.repoName}'${repoId !== '' ? ` (${repoId})` : ''}.\nKey: ${record.projectKey}\nCredentials stored (DSH home, 0600).${resolveNote}\nSync: ${sync.mode} — ${sync.steps.join(' → ') || sync.detail}` +
|
|
152
|
+
(sync.ok || sync.mode === 'local-only' ? '' : '\nThe service may be down or the token wrong — /chapters-status carries the detail; nothing else is affected.'),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// ---- mode 3: https upstream — token required unless loopback
|
|
156
|
+
if (!/^https?:\/\//.test(target)) {
|
|
157
|
+
return { kind: 'error', text: 'usage: /chapters-link [<local-path> | <https-url> <token>] \u2014 (no args shows the current upstream)' };
|
|
158
|
+
}
|
|
159
|
+
const token = parts[1];
|
|
160
|
+
const host = (() => { try {
|
|
161
|
+
return new URL(target).hostname;
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return '';
|
|
165
|
+
} })();
|
|
166
|
+
const loopback = host === '127.0.0.1' || host === 'localhost' || host === '::1';
|
|
167
|
+
if (token === undefined && !loopback) {
|
|
168
|
+
return { kind: 'error', text: 'A credential is required for a network upstream: /chapters-link <url> <token> (stored 0600 under the DSH home \u2014 never in the project). Local paths need none: /chapters-link ./vendor/kb.git' };
|
|
169
|
+
}
|
|
170
|
+
const resolved = resolveProject(cwd, undefined, target);
|
|
171
|
+
const record = {
|
|
172
|
+
projectKey: resolved.projectKey,
|
|
173
|
+
slug: (resolved.remote ?? target).split('/').pop().replace(/\.git$/, ''),
|
|
174
|
+
remote: target,
|
|
175
|
+
harnessId: config.harnessId,
|
|
176
|
+
linkedAt: new Date().toISOString(),
|
|
177
|
+
cwd,
|
|
178
|
+
};
|
|
179
|
+
if (token !== undefined)
|
|
180
|
+
writeToken(record.projectKey, token);
|
|
181
|
+
table.put(record.projectKey, record);
|
|
182
|
+
const sync = await syncNow(cwd, record, token ?? readToken(cwd, config.artifactStoreRoot, record.projectKey));
|
|
183
|
+
const hint = sync.ok || sync.mode === 'local-only'
|
|
184
|
+
? ''
|
|
185
|
+
: '\nThe upstream may not exist yet \u2014 create the private repo (GitHub creates one on push for a suitably-scoped token), or point at a local path: /chapters-link ./vendor/kb.git';
|
|
186
|
+
return { kind: 'success', text: `Linked to ${target}.\nKey: ${record.projectKey}${token === undefined ? '\n(no credentials: loopback upstream)' : '\nCredentials stored (DSH home, 0600).'}\nSync: ${sync.mode} \u2014 ${sync.steps.join(' \u2192 ') || sync.detail}${hint}` };
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return { kind: 'error', text: `chapters-link failed: ${String(error?.message ?? error)}`.slice(0, 300) };
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
/** one immediate sync pass for a fresh record (explicit project wins). */
|
|
194
|
+
async function syncNow(cwd, record, token) {
|
|
195
|
+
if (config.scheduler !== undefined)
|
|
196
|
+
return config.scheduler.run(cwd, 'link', record);
|
|
197
|
+
return runSync({
|
|
198
|
+
cwd, storeRoot: config.artifactStoreRoot, cloneDir: DEFAULT_CLONE_DIR,
|
|
199
|
+
project: record, ...(token !== undefined && token !== null ? { token } : {}),
|
|
200
|
+
force: true,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
const statusCommand = {
|
|
204
|
+
name: 'chapters-status',
|
|
205
|
+
description: 'Show the knowledge-repo mirror status for this project.',
|
|
206
|
+
input: { hint: '[prints project, remote, and last sync result]' },
|
|
207
|
+
async handler(invocation) {
|
|
208
|
+
const cwd = cwdOf(invocation.agent);
|
|
209
|
+
const project = projectForCwd(domain.table('projects').entries(), cwd);
|
|
210
|
+
const status = readSyncStatus(cwd, config.artifactStoreRoot);
|
|
211
|
+
if (project === undefined && status === null) {
|
|
212
|
+
return { kind: 'success', text: 'No knowledge repository is linked yet. Link one with /chapters-link <https-remote-url> [token].' };
|
|
213
|
+
}
|
|
214
|
+
const lines = [];
|
|
215
|
+
if (project !== undefined) {
|
|
216
|
+
const pending = config.scheduler?.hasPending(cwd) === true;
|
|
217
|
+
lines.push(`Project: ${project.slug} \u00B7 key ${project.projectKey}`);
|
|
218
|
+
lines.push(`Remote: ${project.remote}`);
|
|
219
|
+
try {
|
|
220
|
+
lines.push(`Provider: ${selectProvider(project).describe(project)}`);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
lines.push('Provider: (kind unrecognized — sync will refuse loudly, nothing silently reroutes)');
|
|
224
|
+
}
|
|
225
|
+
lines.push(pending ? 'Sync: a push is pending (debounced)' : `Sync: ${status?.mode ?? 'never run'}${pending ? '' : ''}`);
|
|
226
|
+
}
|
|
227
|
+
if (status !== null) {
|
|
228
|
+
lines.push(`Last sync: ${status.at} \u2014 ${status.lastOk ? 'synced' : `${status.mode ?? 'local-only'}: ${status.detail}`}`);
|
|
229
|
+
lines.push(` ${(status.steps ?? []).join(' \u2192 ')}`);
|
|
230
|
+
}
|
|
231
|
+
if (config.enrich !== undefined)
|
|
232
|
+
lines.push(config.enrich.statusLine());
|
|
233
|
+
return { kind: 'success', text: lines.join('\n') };
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
const enrichCommand = {
|
|
237
|
+
name: 'chapters-enrich',
|
|
238
|
+
description: 'P2 chapter enrichment (record \u00A76): run a batch now, set the model, or report pending work.',
|
|
239
|
+
input: { hint: 'run | model <provider/model | clear> | report' },
|
|
240
|
+
async handler(invocation) {
|
|
241
|
+
if (config.enrich === undefined)
|
|
242
|
+
return { kind: 'error', text: 'enrichment is not wired on this plane' };
|
|
243
|
+
const parts = (invocation.rawInput ?? '').trim().split(/\s+/).filter((p) => p.length > 0);
|
|
244
|
+
const verb = parts[0] ?? 'help';
|
|
245
|
+
try {
|
|
246
|
+
if (verb === 'model') {
|
|
247
|
+
const arg = parts[1];
|
|
248
|
+
if (arg === undefined) {
|
|
249
|
+
const o = config.enrich.modelOverride();
|
|
250
|
+
return { kind: 'success', text: `enrichment model: ${o ?? 'conversation default'}${o === undefined || o === null ? '' : ' (override)'}` };
|
|
251
|
+
}
|
|
252
|
+
await config.enrich.setModelOverride(arg === 'clear' ? null : arg);
|
|
253
|
+
return { kind: 'success', text: arg === 'clear' ? 'enrichment model reset to the conversation default' : `enrichment model set to ${arg} (pending chapters re-qualify under the new key)` };
|
|
254
|
+
}
|
|
255
|
+
if (verb === 'run') {
|
|
256
|
+
const r = await config.enrich.runNow(cwdOf(invocation.agent));
|
|
257
|
+
return { kind: 'success', text: `enrichment: processed ${r.processed} chapter(s); ${r.remaining} pending` };
|
|
258
|
+
}
|
|
259
|
+
if (verb === 'report') {
|
|
260
|
+
return { kind: 'success', text: `${config.enrich.statusLine()}\npending: ${await config.enrich.pendingCount()} chapter(s)` };
|
|
261
|
+
}
|
|
262
|
+
return { kind: 'success', text: 'usage: /chapters-enrich run | model <provider/model | clear> | report' };
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
return { kind: 'error', text: `chapters-enrich failed: ${String(error?.message ?? error).slice(0, 200)}` };
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
try {
|
|
270
|
+
const d1 = commands.register(linkCommand);
|
|
271
|
+
if (typeof d1 === 'function')
|
|
272
|
+
disposers.push(d1);
|
|
273
|
+
const d2 = commands.register(statusCommand);
|
|
274
|
+
if (typeof d2 === 'function')
|
|
275
|
+
disposers.push(d2);
|
|
276
|
+
const d3 = commands.register(enrichCommand);
|
|
277
|
+
if (typeof d3 === 'function')
|
|
278
|
+
disposers.push(d3);
|
|
279
|
+
if (config.rules !== undefined) {
|
|
280
|
+
const rulesFn = config.rules;
|
|
281
|
+
const rulesCommandDef = {
|
|
282
|
+
name: 'chapters-rule',
|
|
283
|
+
description: 'Project rules (record \u00A77): propose, review, approve per machine, revoke.',
|
|
284
|
+
input: { hint: 'add <category> <text> | list [--all|--proposed|--category <c>] | approve <id> | revoke <id>' },
|
|
285
|
+
async handler(invocation) {
|
|
286
|
+
const r = await rulesFn(cwdOf(invocation.agent), invocation.rawInput ?? '');
|
|
287
|
+
return { kind: r.kind, text: r.text };
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
const d4 = commands.register(rulesCommandDef);
|
|
291
|
+
if (typeof d4 === 'function')
|
|
292
|
+
disposers.push(d4);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
// LOUD on the operator's console too — a swallowed register error here is
|
|
297
|
+
// how r35g's silent command-absence cost an extra boot to diagnose.
|
|
298
|
+
const message = `dsh-chapters: host command registration failed (${String(error)})`;
|
|
299
|
+
ctx.logger?.warn?.(message);
|
|
300
|
+
console.error(message);
|
|
301
|
+
}
|
|
302
|
+
return () => { for (const d of disposers)
|
|
303
|
+
d(); };
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EACL,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,GAElG,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACtF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC3G,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,M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B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAA;YAC5B,MAAM,eAAe,GAAG;gBACtB,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,+EAA+E;gBAC5F,KAAK,EAAE,EAAE,IAAI,EAAE,6FAA6F,EAAE;gBAC9G,KAAK,CAAC,OAAO,CAAC,UAAiD;oBAC7D,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAA;oBAC3E,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;gBACvC,CAAC;aACF,CAAA;YACD,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;YAC7C,IAAI,OAAO,EAAE,KAAK,UAAU;gBAAE,SAAS,CAAC,IAAI,CAAC,EAAgB,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0EAA0E;QAC1E,oEAAoE;QACpE,MAAM,OAAO,GAAG,mDAAmD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAA;QACnF,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,CAAA;QAC3B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxB,CAAC;IACD,OAAO,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,CAAC,EAAE,CAAA,CAAC,CAAC,CAAA;AACjD,CAAC"}
|
package/lib/compose.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CollectionSignature } from './signature.ts';
|
|
2
|
+
import type { ChapterRange } from './types.ts';
|
|
3
|
+
import type { SessionEventLike } from './types.ts';
|
|
4
|
+
export interface ComposeConfig {
|
|
5
|
+
/** Merge threshold τ in [0,1]: collections merge while overlap score ≥ τ. */
|
|
6
|
+
mergeThreshold: number;
|
|
7
|
+
/** Estimated-token cap per chapter; overshoot forces a split. */
|
|
8
|
+
chapterLimit: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ComposeResult {
|
|
11
|
+
chapters: ChapterRange[];
|
|
12
|
+
notes: string[];
|
|
13
|
+
/** Span events belonging to turns that did not complete inside the span. */
|
|
14
|
+
unarchivedSeqs: number[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Overlap score in [0,1]: path matches weigh 2× (same file ≈ same task),
|
|
18
|
+
* command and term matches 1×; denominator is the union, so a collection
|
|
19
|
+
* with mostly NEW signal scores low against the running chapter.
|
|
20
|
+
*/
|
|
21
|
+
export declare function signatureScore(a: CollectionSignature, b: CollectionSignature): number;
|
|
22
|
+
/**
|
|
23
|
+
* Compose the span [spanStart, spanEnd] of `events` into topic-sequential
|
|
24
|
+
* chapters from `collections` (the session's stored per-turn signatures).
|
|
25
|
+
*
|
|
26
|
+
* Returns no chapters when the span holds no COMPLETED collections — the
|
|
27
|
+
* caller then falls back to its legacy size-based behavior rather than
|
|
28
|
+
* archiving nothing-and-claiming-to.
|
|
29
|
+
*/
|
|
30
|
+
export declare function composeChapters(events: readonly SessionEventLike[], spanStart: number, spanEnd: number, collections: readonly CollectionSignature[], config: ComposeConfig): ComposeResult;
|
package/lib/compose.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Topic-sequential composition (knowledge-repo.md §4.2–4.4).
|
|
3
|
+
*
|
|
4
|
+
* The user requirement in the record: consecutive message collections that
|
|
5
|
+
* reference the SAME TASK merge into one chapter; a chapter splits only when
|
|
6
|
+
* the task changes (signature overlap < τ) or the chapter outgrows a limit.
|
|
7
|
+
* Greedy, sequential, deterministic — and composed from the per-turn
|
|
8
|
+
* signatures already stored at turn/end (§4.1), so archive time is O(turns).
|
|
9
|
+
*
|
|
10
|
+
* Completeness guard (§4.3): only collections whose turn COMPLETED inside the
|
|
11
|
+
* span are archived; anything cut by a span boundary stays live and is noted,
|
|
12
|
+
* never silently dropped and never silently included.
|
|
13
|
+
*
|
|
14
|
+
* Pure module: events + stored collections + config in, chapter ranges out.
|
|
15
|
+
* The titles/summaries come from deriveIdentity (engine-core) — the same
|
|
16
|
+
* deterministic derivation the rest of the plugin uses; P2 enrichment may
|
|
17
|
+
* relabel later, never re-chapter (append-only, §4.4).
|
|
18
|
+
*/
|
|
19
|
+
import { deriveIdentity } from "./engine-core.js";
|
|
20
|
+
const union = (a, b) => new Set([...a, ...b]);
|
|
21
|
+
const inter = (a, b) => {
|
|
22
|
+
const set = new Set(a);
|
|
23
|
+
return b.reduce((n, v) => n + (set.has(v) ? 1 : 0), 0);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Overlap score in [0,1]: path matches weigh 2× (same file ≈ same task),
|
|
27
|
+
* command and term matches 1×; denominator is the union, so a collection
|
|
28
|
+
* with mostly NEW signal scores low against the running chapter.
|
|
29
|
+
*/
|
|
30
|
+
export function signatureScore(a, b) {
|
|
31
|
+
const num = 2 * inter(a.paths, b.paths) + inter(a.commands, b.commands) + inter(a.terms, b.terms);
|
|
32
|
+
const den = 2 * union(a.paths, b.paths).size + union(a.commands, b.commands).size + union(a.terms, b.terms).size;
|
|
33
|
+
if (den === 0)
|
|
34
|
+
return 0;
|
|
35
|
+
return num / den;
|
|
36
|
+
}
|
|
37
|
+
const messagesOf = (events, lo, hi) => events
|
|
38
|
+
.filter((e) => e.seq >= lo && e.seq <= hi && (e.type === 'user/message' || e.type === 'assistant/message'))
|
|
39
|
+
.map((e) => {
|
|
40
|
+
const d = (e.data ?? {});
|
|
41
|
+
const message = (d.message ?? d);
|
|
42
|
+
const content = Array.isArray(message.content)
|
|
43
|
+
? message.content
|
|
44
|
+
.filter((b) => b.type === 'text')
|
|
45
|
+
.map((b) => ({ type: 'text', ...(b.text !== undefined ? { text: b.text } : {}) }))
|
|
46
|
+
: [];
|
|
47
|
+
return { role: e.type === 'assistant/message' ? 'assistant' : 'user', content };
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Compose the span [spanStart, spanEnd] of `events` into topic-sequential
|
|
51
|
+
* chapters from `collections` (the session's stored per-turn signatures).
|
|
52
|
+
*
|
|
53
|
+
* Returns no chapters when the span holds no COMPLETED collections — the
|
|
54
|
+
* caller then falls back to its legacy size-based behavior rather than
|
|
55
|
+
* archiving nothing-and-claiming-to.
|
|
56
|
+
*/
|
|
57
|
+
export function composeChapters(events, spanStart, spanEnd, collections, config) {
|
|
58
|
+
const notes = [];
|
|
59
|
+
const inSpan = (c) => c.seqs.length > 0 && c.seqs[0] >= spanStart && c.seqs[c.seqs.length - 1] <= spanEnd;
|
|
60
|
+
const usable = collections.filter(inSpan).sort((a, b) => a.seqs[0] - b.seqs[0]);
|
|
61
|
+
if (usable.length === 0) {
|
|
62
|
+
const unarchived = events.filter((e) => e.seq >= spanStart && e.seq <= spanEnd).map((e) => e.seq);
|
|
63
|
+
notes.push('no completed collections in span — legacy segmentation applies');
|
|
64
|
+
return { chapters: [], notes, unarchivedSeqs: unarchived };
|
|
65
|
+
}
|
|
66
|
+
const covered = new Set(usable.flatMap((c) => c.seqs));
|
|
67
|
+
const unarchivedSeqs = events
|
|
68
|
+
.filter((e) => e.seq >= spanStart && e.seq <= spanEnd && !covered.has(e.seq))
|
|
69
|
+
.map((e) => e.seq);
|
|
70
|
+
if (unarchivedSeqs.length > 0) {
|
|
71
|
+
notes.push(`incomplete turn content (seqs ${unarchivedSeqs[0]}..${unarchivedSeqs[unarchivedSeqs.length - 1]}) `
|
|
72
|
+
+ 'stays live — a chapter only archives completed turns');
|
|
73
|
+
}
|
|
74
|
+
const runningOf = (c) => ({
|
|
75
|
+
first: c, last: c, paths: new Set(c.paths), commands: new Set(c.commands), terms: new Set(c.terms),
|
|
76
|
+
size: c.size, startSeq: c.seqs[0], endSeq: c.seqs[c.seqs.length - 1],
|
|
77
|
+
});
|
|
78
|
+
const scoreAgainst = (c, r) => Math.max(signatureScore(c, r.first), signatureScore(c, r.last));
|
|
79
|
+
// primary match: the first path of c equals the first path of either member
|
|
80
|
+
// (with a prefix tolerance: 'src/render' vs 'src/render.ts' — the same file
|
|
81
|
+
// named from prose vs tool args).
|
|
82
|
+
const primaryOf = (sig) => sig.paths[0];
|
|
83
|
+
const primaryEq = (a, b) => {
|
|
84
|
+
if (a === undefined || b === undefined || a === '' || b === '')
|
|
85
|
+
return false;
|
|
86
|
+
return a === b || a.startsWith(b + '.') || b.startsWith(a + '.');
|
|
87
|
+
};
|
|
88
|
+
const primaryMatch = (c, r) => primaryEq(primaryOf(c), primaryOf(r.first)) || primaryEq(primaryOf(c), primaryOf(r.last));
|
|
89
|
+
const chapters = [];
|
|
90
|
+
let running = runningOf(usable[0]);
|
|
91
|
+
for (const c of usable.slice(1)) {
|
|
92
|
+
// r28 (first live topic test): overlap Jaccard ALONE never reaches τ on
|
|
93
|
+
// real research turns — a same-topic pair touching 5–6 files each scores
|
|
94
|
+
// ~0.08 because one shared path dilutes in a union of ~10. The signal
|
|
95
|
+
// that actually separates is the PRIMARY path (paths[0]: the first file
|
|
96
|
+
// the turn touched): identical across the render pair, distinct at every
|
|
97
|
+
// topic change. Merge on (score ≥ τ) OR (primary match).
|
|
98
|
+
const merge = (scoreAgainst(c, running) >= config.mergeThreshold || primaryMatch(c, running))
|
|
99
|
+
&& running.size + c.size <= config.chapterLimit;
|
|
100
|
+
if (merge) {
|
|
101
|
+
for (const p of c.paths)
|
|
102
|
+
running.paths.add(p);
|
|
103
|
+
for (const q of c.commands)
|
|
104
|
+
running.commands.add(q);
|
|
105
|
+
for (const t of c.terms)
|
|
106
|
+
running.terms.add(t);
|
|
107
|
+
running.size += c.size;
|
|
108
|
+
running.last = c;
|
|
109
|
+
running.endSeq = c.seqs[c.seqs.length - 1];
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
close();
|
|
113
|
+
running = runningOf(c);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
close();
|
|
117
|
+
function close() {
|
|
118
|
+
const lo = running.startSeq;
|
|
119
|
+
const hi = running.endSeq;
|
|
120
|
+
const identity = deriveIdentity(messagesOf(events, lo, hi), false);
|
|
121
|
+
const pathsHint = [...running.paths].slice(0, 3).join(', ');
|
|
122
|
+
chapters.push({
|
|
123
|
+
title: identity.title,
|
|
124
|
+
summary: `${identity.summary}${pathsHint !== '' ? ` · ${pathsHint}` : ''}`,
|
|
125
|
+
startSeq: lo,
|
|
126
|
+
endSeq: hi,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return { chapters, notes, unarchivedSeqs };
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,cAAc,EAAsB,MAAM,kBAAkB,CAAA;AAmBrE,MAAM,KAAK,GAAG,CAAC,CAAoB,EAAE,CAAoB,EAAe,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;AAChG,MAAM,KAAK,GAAG,CAAC,CAAoB,EAAE,CAAoB,EAAU,EAAE;IACnE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAA;IACtB,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACxD,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,CAAsB,EAAE,CAAsB;IAC3E,MAAM,GAAG,GAAG,CAAC,GAAG,KAA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