@hearsay-tools/squawk 0.18.0-pr4345.8484 → 0.18.0-pr4350.8487.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/dist/contract/index.js +2 -23
- package/dist/contract/session-context.d.ts +8 -54
- package/dist/data-gitignore.js +0 -1
- package/dist/data-gitignore.js.map +1 -1
- package/dist/runners/antigravity/acp/session.d.ts +7 -0
- package/dist/runners/antigravity/acp/session.js +11 -0
- package/dist/runners/antigravity/acp/session.js.map +1 -1
- package/dist/runners/antigravity/acp/transport.d.ts +1 -0
- package/dist/runners/antigravity/acp/transport.js +13 -2
- package/dist/runners/antigravity/acp/transport.js.map +1 -1
- package/dist/runners/antigravity/antigravity-session.d.ts +13 -0
- package/dist/runners/antigravity/antigravity-session.js +178 -15
- package/dist/runners/antigravity/antigravity-session.js.map +1 -1
- package/dist/server/server.d.ts +32 -72
- package/dist/server/session-context-routes.d.ts +15 -35
- package/dist/server/session-context-routes.js +6 -6
- package/dist/server/session-context-routes.js.map +1 -1
- package/dist/session-context-file.d.ts +3 -3
- package/dist/session-context-file.js +16 -45
- package/dist/session-context-file.js.map +1 -1
- package/dist/session-context.d.ts +9 -18
- package/dist/session-context.js +47 -118
- package/dist/session-context.js.map +1 -1
- package/package.json +4 -4
- package/scripts/mock-acp.mjs +76 -4
- package/web/dist/assets/{accounts-section-BT-KA5Aw.js → accounts-section-CuihHvuE.js} +1 -1
- package/web/dist/assets/{activity-motion-BL2bQufZ.js → activity-motion-bKmIl_Ai.js} +1 -1
- package/web/dist/assets/{activity-route-CfLjbvX-.js → activity-route-Bnz_NdUs.js} +1 -1
- package/web/dist/assets/{agent-config-section-isgedTYT.js → agent-config-section-uQrQrvBR.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-DnGa0vZn.js → agent-defaults-section-1UTSo5HV.js} +1 -1
- package/web/dist/assets/{appearance-BE_8n1rr.js → appearance-CZ0kce28.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-C83q8HKD.js → archive-on-merge-field-CEyCpweg.js} +1 -1
- package/web/dist/assets/{automations-route-CpDyl3jW.js → automations-route-Dq90emTh.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-ZJL9SvlZ.js → commit-diff-panel-Btc38N2Q.js} +1 -1
- package/web/dist/assets/{diff-t0VC73su.js → diff-C3-63Zgu.js} +2 -2
- package/web/dist/assets/{diff-view-BxNyE6ve.js → diff-view-D2O2Nm5P.js} +1 -1
- package/web/dist/assets/{file-preview-DQ-T-D8H.js → file-preview-Bnq2OKGK.js} +1 -1
- package/web/dist/assets/{folder-browser-CbWAXTsX.js → folder-browser-Bn83Rjyn.js} +1 -1
- package/web/dist/assets/{git-toolbar-iZ2mG7oO.js → git-toolbar-RA8rF90D.js} +1 -1
- package/web/dist/assets/{github-BnHg2x4a.js → github-BRAMTLRU.js} +1 -1
- package/web/dist/assets/{global-activity-route-6Fpj2ek4.js → global-activity-route-Ii_-Fqqo.js} +1 -1
- package/web/dist/assets/{index-CMHOE-jE.js → index-DCw_bX8I.js} +5 -5
- package/web/dist/assets/{label-Dbp-6aiT.js → label-tOtTf55G.js} +1 -1
- package/web/dist/assets/{markdown-D1BGpE3v.js → markdown-G8tjpJd_.js} +1 -1
- package/web/dist/assets/{notifications-section-DnC9npL3.js → notifications-section-Fk_ebhy_.js} +1 -1
- package/web/dist/assets/{open-in-menu-mDtfa4ES.js → open-in-menu-xzDJ4_Tv.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-Ba2Tc4Uw.js → preview-pane-connected-8HkdMxOW.js} +1 -1
- package/web/dist/assets/{project-location-c1oHm2yu.js → project-location-C9WLgY3A.js} +1 -1
- package/web/dist/assets/{projects-section-DwabmXYr.js → projects-section-Dmj4JFoi.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-Dy3jde_2.js → prompt-templates-section-DzfD2GES.js} +1 -1
- package/web/dist/assets/queries-DRpvYgai.js +1 -0
- package/web/dist/assets/{reference-chip-1BEDWxcS.js → reference-chip-zRuFkaGy.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-B07kuoGY.js → remote-settings-notice-CYiMrnys.js} +1 -1
- package/web/dist/assets/{repo-git-CIWMWcB1.js → repo-git-B3tTtvIQ.js} +1 -1
- package/web/dist/assets/{report-reader-au3hsVnq.js → report-reader-DBGA_8LA.js} +1 -1
- package/web/dist/assets/{reports-DhKekN8B.js → reports-B-Q6u2X6.js} +1 -1
- package/web/dist/assets/{resources-section-CaTs8f4X.js → resources-section-C5ndEonC.js} +1 -1
- package/web/dist/assets/{run-header-oFGKOVQR.js → run-header-DK4CZ3hY.js} +1 -1
- package/web/dist/assets/session-context-section-BAw6x6P2.js +119 -0
- package/web/dist/assets/{settings-agent-picker-B-bLF5nf.js → settings-agent-picker-fkaIrncp.js} +1 -1
- package/web/dist/assets/{settings-shell-FcgFxanP.js → settings-shell-dzuuT5tw.js} +1 -1
- package/web/dist/assets/{sidebar-section-C_-EzQXK.js → sidebar-section-BIQilcgt.js} +1 -1
- package/web/dist/assets/{skills-Js4Ees5K.js → skills-C-jo20DK.js} +1 -1
- package/web/dist/assets/{task-changes-G0A9NfV-.js → task-changes-DnG-9vJh.js} +1 -1
- package/web/dist/assets/{task-commits-YYe7KUYB.js → task-commits-mqs3nfjk.js} +1 -1
- package/web/dist/assets/{task-files-BKgN092S.js → task-files-DKB3Xp3N.js} +1 -1
- package/web/dist/assets/{task-github-item-gznr9Fxa.js → task-github-item-BA7W64bU.js} +1 -1
- package/web/dist/assets/{task-groups-Ziytm1Sm.js → task-groups-ClNnAPRA.js} +1 -1
- package/web/dist/assets/{task-thread-CrFj20JU.js → task-thread-B8zgMgtO.js} +1 -1
- package/web/dist/assets/{tasks-table-wTQZb7nJ.js → tasks-table-CE_VVk0w.js} +1 -1
- package/web/dist/assets/{thread-state-B0bNtkoV.js → thread-state-8okW1FLM.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-BAOFoVNc.js → use-hand-to-agent-state-BwLk3gNd.js} +1 -1
- package/web/dist/assets/{workflows-DpRgaKR7.js → workflows-BhQJM4JW.js} +1 -1
- package/web/dist/assets/{workspace-tools-D6UQj5mq.js → workspace-tools-BZs10pQZ.js} +1 -1
- package/web/dist/assets/{worktrees-section-DXMfub26.js → worktrees-section-BTNZUVnW.js} +1 -1
- package/web/dist/index.html +8 -8
- package/web/dist/assets/queries-dOBokhuR.js +0 -1
- package/web/dist/assets/session-context-section-DBB1qz9r.js +0 -119
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
import type { ProjectApiEnv } from './server-types.ts';
|
|
2
2
|
/**
|
|
3
|
-
* Settings → Session context (hearsay-tools/squawk#4308
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Settings → Session context (hearsay-tools/squawk#4308). Writing `context.yaml` needs no
|
|
4
|
+
* `settingsAdmin`: the file runs no host command, and its file includes stay inside the worktree
|
|
5
|
+
* (ADR 0055 gates only settings that persist host commands).
|
|
6
6
|
*/
|
|
7
7
|
export declare function createSessionContextRoutes(): import("hono/hono-base").HonoBase<ProjectApiEnv, {
|
|
8
8
|
"/session-context": {
|
|
9
9
|
$get: {
|
|
10
10
|
output: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readOnlyReason: string | null;
|
|
18
|
-
};
|
|
19
|
-
shared: {
|
|
20
|
-
path: string;
|
|
21
|
-
exists: boolean;
|
|
22
|
-
content: string;
|
|
23
|
-
tracked: boolean;
|
|
24
|
-
unreadableReason: string | null;
|
|
25
|
-
};
|
|
11
|
+
path: string;
|
|
12
|
+
exists: boolean;
|
|
13
|
+
content: string;
|
|
14
|
+
version: string | null;
|
|
15
|
+
writable: boolean;
|
|
16
|
+
readOnlyReason: string | null;
|
|
26
17
|
};
|
|
27
18
|
outputFormat: "json";
|
|
28
19
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -40,10 +31,8 @@ export declare function createSessionContextRoutes(): import("hono/hono-base").H
|
|
|
40
31
|
}[];
|
|
41
32
|
blocks: {
|
|
42
33
|
id: string;
|
|
43
|
-
source: 'built-in' | import("../session-context.ts").SessionContextRuleSource;
|
|
44
34
|
target: import("../session-context.ts").SessionContextRule['target'] | 'built-in' | null;
|
|
45
35
|
status: import("../session-context.ts").SessionContextReportStatus | 'not-for-role';
|
|
46
|
-
overridesShared: boolean;
|
|
47
36
|
bytes: number | null;
|
|
48
37
|
reason: string | null;
|
|
49
38
|
sources: string[];
|
|
@@ -67,21 +56,12 @@ export declare function createSessionContextRoutes(): import("hono/hono-base").H
|
|
|
67
56
|
"/session-context": {
|
|
68
57
|
$put: {
|
|
69
58
|
output: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
readOnlyReason: string | null;
|
|
77
|
-
};
|
|
78
|
-
shared: {
|
|
79
|
-
path: string;
|
|
80
|
-
exists: boolean;
|
|
81
|
-
content: string;
|
|
82
|
-
tracked: boolean;
|
|
83
|
-
unreadableReason: string | null;
|
|
84
|
-
};
|
|
59
|
+
path: string;
|
|
60
|
+
exists: boolean;
|
|
61
|
+
content: string;
|
|
62
|
+
version: string | null;
|
|
63
|
+
writable: boolean;
|
|
64
|
+
readOnlyReason: string | null;
|
|
85
65
|
};
|
|
86
66
|
outputFormat: "json";
|
|
87
67
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import { sessionContextPreviewRequestSchema, setSessionContextSchema } from '../contract/index.js';
|
|
3
3
|
import { previewSessionContext } from '../session-context.js';
|
|
4
|
-
import {
|
|
4
|
+
import { readSessionContextFile, writeSessionContextFile } from '../session-context-file.js';
|
|
5
5
|
import { jsonZodValidator } from './validators.js';
|
|
6
6
|
/**
|
|
7
|
-
* Settings → Session context (hearsay-tools/squawk#4308
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Settings → Session context (hearsay-tools/squawk#4308). Writing `context.yaml` needs no
|
|
8
|
+
* `settingsAdmin`: the file runs no host command, and its file includes stay inside the worktree
|
|
9
|
+
* (ADR 0055 gates only settings that persist host commands).
|
|
10
10
|
*/
|
|
11
11
|
export function createSessionContextRoutes() {
|
|
12
12
|
return new Hono()
|
|
13
|
-
.get('/session-context', async (c) => c.json(await
|
|
13
|
+
.get('/session-context', async (c) => c.json(await readSessionContextFile(c.get('project').root)))
|
|
14
14
|
.post('/session-context/preview', jsonZodValidator(sessionContextPreviewRequestSchema), (c) => {
|
|
15
15
|
const body = c.req.valid('json');
|
|
16
16
|
return c.json(previewSessionContext({ projectRoot: c.get('project').root, content: body.content, role: body.role }));
|
|
@@ -20,7 +20,7 @@ export function createSessionContextRoutes() {
|
|
|
20
20
|
const out = await writeSessionContextFile(c.get('project').root, body.content, body.version);
|
|
21
21
|
if (!out.ok)
|
|
22
22
|
return c.json({ error: out.error }, out.status);
|
|
23
|
-
return c.json(out.
|
|
23
|
+
return c.json(out.file);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=session-context-routes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-context-routes.js","sourceRoot":"","sources":["../../src/server/session-context-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,kCAAkC,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC3H,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"session-context-routes.js","sourceRoot":"","sources":["../../src/server/session-context-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,kCAAkC,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC3H,OAAO,EAAE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AE,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7D,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function
|
|
1
|
+
import { type SessionContextFile } from './contract/index.js';
|
|
2
|
+
export declare function readSessionContextFile(projectRoot: string): Promise<SessionContextFile>;
|
|
3
3
|
export type SessionContextWrite = {
|
|
4
4
|
ok: true;
|
|
5
|
-
|
|
5
|
+
file: SessionContextFile;
|
|
6
6
|
} | {
|
|
7
7
|
ok: false;
|
|
8
8
|
status: 400 | 409 | 500;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import { lstat, mkdir, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join, relative } from 'node:path';
|
|
4
|
-
import { SESSION_CONTEXT_FILE_MAX_BYTES
|
|
5
|
-
import { ensureDataGitignore } from './data-gitignore.js';
|
|
6
|
-
import { runGit } from './git-command.js';
|
|
4
|
+
import { SESSION_CONTEXT_FILE_MAX_BYTES } from './contract/index.js';
|
|
7
5
|
import { fallbackProjectWriteError, readProjectPath } from './project-paths.js';
|
|
8
6
|
import { parseSessionContextText } from './session-context.js';
|
|
9
7
|
/**
|
|
10
|
-
* The cockpit's read of
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* file such as `config.json
|
|
8
|
+
* The cockpit's read and write of the project's `context.yaml` (hearsay-tools/squawk#4308). It reads
|
|
9
|
+
* the same path a launch reads, and writes it back in place: atomically, only over the version the
|
|
10
|
+
* editor read, and only text with no problems. Fallback project data stays read only, and so does a
|
|
11
|
+
* file reached through a symbolic link: a remote user could otherwise point the editor at another
|
|
12
|
+
* file, such as `config.json`, and write settings that need settings administration.
|
|
15
13
|
*/
|
|
16
|
-
const SHARED_FILE = 'context.yaml';
|
|
17
|
-
const LOCAL_FILE = 'context.local.yaml';
|
|
18
14
|
function hashBytes(content) {
|
|
19
15
|
return createHash('sha256').update(content, 'utf8').digest('hex');
|
|
20
16
|
}
|
|
@@ -77,15 +73,6 @@ async function readCurrent(projectRoot, path) {
|
|
|
77
73
|
return { exists: true, unreadable: `it cannot be read (${error.code ?? 'error'})` };
|
|
78
74
|
}
|
|
79
75
|
}
|
|
80
|
-
async function isGitTracked(projectRoot, relPath) {
|
|
81
|
-
try {
|
|
82
|
-
const { stdout } = await runGit(['ls-files', '--cached', '--', relPath.replace(/\\/g, '/')], { cwd: projectRoot, timeout: 10_000 });
|
|
83
|
-
return stdout.trim().length > 0;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
76
|
function answer(projectRoot, path, current) {
|
|
90
77
|
const shown = relative(projectRoot, path);
|
|
91
78
|
const fallback = fallbackProjectWriteError(path);
|
|
@@ -103,29 +90,14 @@ function answer(projectRoot, path, current) {
|
|
|
103
90
|
writable: fallback === undefined, readOnlyReason: fallback ?? null,
|
|
104
91
|
};
|
|
105
92
|
}
|
|
106
|
-
async function
|
|
107
|
-
const path = readProjectPath(projectRoot,
|
|
108
|
-
|
|
109
|
-
const current = await readCurrent(projectRoot, path);
|
|
110
|
-
if (!current.exists) {
|
|
111
|
-
const unreadableReason = current.unwritable ? `Squawk cannot read ${shown}: ${current.unwritable}.` : null;
|
|
112
|
-
return { path: shown, exists: false, content: '', tracked: false, unreadableReason };
|
|
113
|
-
}
|
|
114
|
-
const tracked = await isGitTracked(projectRoot, shown);
|
|
115
|
-
if ('unreadable' in current) {
|
|
116
|
-
return { path: shown, exists: true, content: '', tracked, unreadableReason: `Squawk cannot read ${shown}: ${current.unreadable}.` };
|
|
117
|
-
}
|
|
118
|
-
return { path: shown, exists: true, content: current.content, tracked, unreadableReason: null };
|
|
119
|
-
}
|
|
120
|
-
export async function readSessionContextState(projectRoot) {
|
|
121
|
-
const localPath = readProjectPath(projectRoot, LOCAL_FILE);
|
|
122
|
-
const [localCurrent, shared] = await Promise.all([readCurrent(projectRoot, localPath), readSharedFile(projectRoot)]);
|
|
123
|
-
return { local: answer(projectRoot, localPath, localCurrent), shared };
|
|
93
|
+
export async function readSessionContextFile(projectRoot) {
|
|
94
|
+
const path = readProjectPath(projectRoot, 'context.yaml');
|
|
95
|
+
return answer(projectRoot, path, await readCurrent(projectRoot, path));
|
|
124
96
|
}
|
|
125
97
|
/** One save at a time per file, so two saves over one version cannot both pass the check. */
|
|
126
98
|
const writing = new Map();
|
|
127
99
|
export function writeSessionContextFile(projectRoot, content, version) {
|
|
128
|
-
const path = readProjectPath(projectRoot,
|
|
100
|
+
const path = readProjectPath(projectRoot, 'context.yaml');
|
|
129
101
|
const previous = writing.get(path) ?? Promise.resolve();
|
|
130
102
|
const next = previous.then(() => writeChecked(projectRoot, path, content, version));
|
|
131
103
|
const settled = next.catch(() => undefined);
|
|
@@ -140,16 +112,15 @@ async function writeChecked(projectRoot, path, content, version) {
|
|
|
140
112
|
return { ok: false, status: 409, error: before.readOnlyReason ?? `${before.path} is read only` };
|
|
141
113
|
if (before.version !== version) {
|
|
142
114
|
const error = before.exists
|
|
143
|
-
? 'context.
|
|
144
|
-
: 'context.
|
|
115
|
+
? 'context.yaml changed on disk since you opened it. Show the disk version, or overwrite it.'
|
|
116
|
+
: 'context.yaml was deleted on disk since you opened it. Show the disk version, or overwrite it.';
|
|
145
117
|
return { ok: false, status: 409, error };
|
|
146
118
|
}
|
|
147
|
-
const first = parseSessionContextText(content
|
|
119
|
+
const first = parseSessionContextText(content).problems[0];
|
|
148
120
|
if (first) {
|
|
149
121
|
const where = first.line === null ? '' : `line ${first.line}: `;
|
|
150
|
-
return { ok: false, status: 400, error: `context.
|
|
122
|
+
return { ok: false, status: 400, error: `context.yaml has problems; fix them to save (${where}${first.message})` };
|
|
151
123
|
}
|
|
152
|
-
ensureDataGitignore(projectRoot);
|
|
153
124
|
// The rename replaces the path itself, never a file a link points to: the check above refuses links.
|
|
154
125
|
const tmp = `${path}.hsq-tmp-${process.pid}-${randomUUID()}`;
|
|
155
126
|
try {
|
|
@@ -160,7 +131,7 @@ async function writeChecked(projectRoot, path, content, version) {
|
|
|
160
131
|
const staged = answer(projectRoot, path, await readCurrent(projectRoot, path));
|
|
161
132
|
if (staged.version !== version || !staged.writable) {
|
|
162
133
|
await rm(tmp, { force: true });
|
|
163
|
-
return { ok: false, status: 409, error: 'context.
|
|
134
|
+
return { ok: false, status: 409, error: 'context.yaml changed on disk since you opened it. Show the disk version, or overwrite it.' };
|
|
164
135
|
}
|
|
165
136
|
await rename(tmp, path);
|
|
166
137
|
}
|
|
@@ -168,6 +139,6 @@ async function writeChecked(projectRoot, path, content, version) {
|
|
|
168
139
|
await rm(tmp, { force: true });
|
|
169
140
|
return { ok: false, status: 500, error: error.message };
|
|
170
141
|
}
|
|
171
|
-
return { ok: true,
|
|
142
|
+
return { ok: true, file: answer(projectRoot, path, await readCurrent(projectRoot, path)) };
|
|
172
143
|
}
|
|
173
144
|
//# sourceMappingURL=session-context-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-context-file.js","sourceRoot":"","sources":["../src/session-context-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"session-context-file.js","sourceRoot":"","sources":["../src/session-context-file.ts"],"names":[],"mappings":"AAAA,OAAO,EA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CAAC;IACrE,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
/** The complete injection prefix — labels and separators included — counted in UTF-8 bytes. */
|
|
11
11
|
export declare const SESSION_CONTEXT_LIMIT_BYTES = 65536;
|
|
12
|
-
/**
|
|
12
|
+
/** Project rules, relative to the project root. Optional: absent means no custom rules. */
|
|
13
13
|
export declare const SESSION_CONTEXT_FILE = ".ai/cezar/context.yaml";
|
|
14
|
-
/** Host-local project rules, relative to the project root (gitignored). Optional. */
|
|
15
|
-
export declare const SESSION_CONTEXT_LOCAL_FILE = ".ai/cezar/context.local.yaml";
|
|
16
14
|
/** The built-in handoff block's id; a custom rule cannot take it. */
|
|
17
15
|
export declare const HANDOFF_CONTEXT_ID = "handoff";
|
|
18
16
|
/** Divides the prefix from the opening message. */
|
|
@@ -21,14 +19,10 @@ export declare const SESSION_CONTEXT_SEPARATOR = "\n\n---\n\n";
|
|
|
21
19
|
export declare const SESSION_CONTEXT_VARIABLES: readonly ['task', 'run.id', 'role', 'workflow.name', 'step.id', 'project.root', 'worktree.root', 'handoff.path'];
|
|
22
20
|
export type SessionContextVariable = typeof SESSION_CONTEXT_VARIABLES[number];
|
|
23
21
|
export type SessionContextRole = 'parent' | 'worker';
|
|
24
|
-
export type SessionContextRuleSource = 'shared' | 'local';
|
|
25
22
|
export interface SessionContextRule {
|
|
26
23
|
id: string;
|
|
27
24
|
target: 'parent' | 'worker' | 'both';
|
|
28
25
|
template: string;
|
|
29
|
-
enabled: boolean;
|
|
30
|
-
source: SessionContextRuleSource;
|
|
31
|
-
overridesShared?: boolean;
|
|
32
26
|
}
|
|
33
27
|
export declare const SESSION_CONTEXT_REPORT_STATUSES: readonly ['applied', 'skipped'];
|
|
34
28
|
export type SessionContextReportStatus = (typeof SESSION_CONTEXT_REPORT_STATUSES)[number];
|
|
@@ -50,9 +44,9 @@ export interface SessionContext {
|
|
|
50
44
|
reports: SessionContextReport[];
|
|
51
45
|
}
|
|
52
46
|
/**
|
|
53
|
-
* Read and validate the project's
|
|
54
|
-
*
|
|
55
|
-
*
|
|
47
|
+
* Read and validate the project's rules. A missing file is no rules and no warning; a file that
|
|
48
|
+
* cannot be read or parsed, or has another version, skips every custom rule with one report;
|
|
49
|
+
* a bad, duplicate or reserved rule skips that rule alone.
|
|
56
50
|
*/
|
|
57
51
|
export declare function loadSessionContextRules(projectRoot: string): {
|
|
58
52
|
rules: SessionContextRule[];
|
|
@@ -73,10 +67,10 @@ export interface ParsedSessionContext {
|
|
|
73
67
|
problems: SessionContextProblem[];
|
|
74
68
|
}
|
|
75
69
|
/**
|
|
76
|
-
* Parse
|
|
77
|
-
*
|
|
70
|
+
* Parse `context.yaml` text once for both readers: a launch takes `rules` and `reports`, the
|
|
71
|
+
* cockpit editor takes `problems`, each with the line it starts on.
|
|
78
72
|
*/
|
|
79
|
-
export declare function parseSessionContextText(text: string
|
|
73
|
+
export declare function parseSessionContextText(text: string): ParsedSessionContext;
|
|
80
74
|
export interface SessionContextInput {
|
|
81
75
|
projectRoot: string;
|
|
82
76
|
/** The receiving session's working directory: where `{{file:…}}` paths resolve. */
|
|
@@ -91,11 +85,9 @@ export declare function buildSessionContext(input: SessionContextInput): Session
|
|
|
91
85
|
export declare const SESSION_CONTEXT_PREVIEW_TEXT_CHARS = 2000;
|
|
92
86
|
export interface SessionContextPreviewBlock {
|
|
93
87
|
id: string;
|
|
94
|
-
source: 'built-in' | SessionContextRuleSource;
|
|
95
88
|
/** `built-in` for the handoff; null for an entry the file could not name a target for. */
|
|
96
89
|
target: SessionContextRule['target'] | 'built-in' | null;
|
|
97
90
|
status: SessionContextReportStatus | 'not-for-role';
|
|
98
|
-
overridesShared: boolean;
|
|
99
91
|
bytes: number | null;
|
|
100
92
|
reason: string | null;
|
|
101
93
|
sources: string[];
|
|
@@ -110,9 +102,8 @@ export interface SessionContextPreview {
|
|
|
110
102
|
limitBytes: number;
|
|
111
103
|
}
|
|
112
104
|
/**
|
|
113
|
-
* Render
|
|
114
|
-
*
|
|
115
|
-
* in the local draft only, so broken shared YAML does not block fixing or saving local rules.
|
|
105
|
+
* Render a draft `context.yaml` the way a launch would: against the project checkout, for one
|
|
106
|
+
* role, with labelled sample values (`<run.id>`) for every task variable and a sample handoff.
|
|
116
107
|
*/
|
|
117
108
|
export declare function previewSessionContext(options: {
|
|
118
109
|
projectRoot: string;
|