@hearsay-tools/squawk 0.18.0-dev.8553 → 0.18.0-dev.8561
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 +23 -2
- package/dist/contract/session-context.d.ts +54 -8
- package/dist/data-gitignore.js +1 -0
- package/dist/data-gitignore.js.map +1 -1
- package/dist/delegation/routes.d.ts +65 -65
- package/dist/server/projects-routes.d.ts +45 -45
- package/dist/server/runners-routes.d.ts +10 -10
- package/dist/server/server.d.ts +72 -32
- package/dist/server/session-context-routes.d.ts +35 -15
- 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 +45 -16
- package/dist/session-context-file.js.map +1 -1
- package/dist/session-context.d.ts +18 -9
- package/dist/session-context.js +118 -47
- package/dist/session-context.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-C4cUskp7.js → accounts-section-W97a1ty2.js} +1 -1
- package/web/dist/assets/{activity-motion-DIX3bcyB.js → activity-motion-zWlkG-V_.js} +1 -1
- package/web/dist/assets/{activity-route-a6v44jSV.js → activity-route-CHfp3gWS.js} +1 -1
- package/web/dist/assets/{agent-config-section-CazTT2mr.js → agent-config-section-Ulvfv3n6.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-CsAvxnzW.js → agent-defaults-section-DuReu1Ob.js} +1 -1
- package/web/dist/assets/{appearance-Bk8WVWHF.js → appearance-DpMIBP4Y.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-CEyCpweg.js → archive-on-merge-field-C83q8HKD.js} +1 -1
- package/web/dist/assets/{automations-route--30oSCSi.js → automations-route-Kro31C3p.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-B5u3nzBH.js → commit-diff-panel-CE7372Fz.js} +1 -1
- package/web/dist/assets/{diff-CVqwOFJx.js → diff-DUljAzi_.js} +2 -2
- package/web/dist/assets/{diff-view-CfDyBNLk.js → diff-view-CYusqV5H.js} +1 -1
- package/web/dist/assets/{file-preview-BXBSy4MR.js → file-preview-Cj3QRSUt.js} +1 -1
- package/web/dist/assets/{folder-browser-Bn83Rjyn.js → folder-browser-CbWAXTsX.js} +1 -1
- package/web/dist/assets/{git-toolbar-CKOW2Bjf.js → git-toolbar-B9t94bg6.js} +1 -1
- package/web/dist/assets/{github-A2sjbmuv.js → github-D0U0_v8D.js} +1 -1
- package/web/dist/assets/{global-activity-route-CZY9ssbt.js → global-activity-route-Co9vGT5h.js} +1 -1
- package/web/dist/assets/{index-Clu9VXJs.js → index-BNqZkH0S.js} +5 -5
- package/web/dist/assets/{label-tOtTf55G.js → label-Dbp-6aiT.js} +1 -1
- package/web/dist/assets/{markdown-C6YMilQS.js → markdown-CzP2Mv9j.js} +1 -1
- package/web/dist/assets/{notifications-section-Ceh7_qob.js → notifications-section-BsHRSzNs.js} +1 -1
- package/web/dist/assets/{open-in-menu-xzDJ4_Tv.js → open-in-menu-mDtfa4ES.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-Ca9btxCQ.js → preview-pane-connected-dvf7gtbB.js} +1 -1
- package/web/dist/assets/{project-location-C9WLgY3A.js → project-location-c1oHm2yu.js} +1 -1
- package/web/dist/assets/{projects-section-C6TNM8uI.js → projects-section-ds7mvM9K.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-DHqBQdL-.js → prompt-templates-section-DsBj0E0U.js} +1 -1
- package/web/dist/assets/queries-dOBokhuR.js +1 -0
- package/web/dist/assets/{reference-chip-zRuFkaGy.js → reference-chip-1BEDWxcS.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-mnASAu6Z.js → remote-settings-notice-BD9jRcE6.js} +1 -1
- package/web/dist/assets/{repo-git-Dc7y1A-S.js → repo-git-j8MdHS3x.js} +1 -1
- package/web/dist/assets/{report-reader-CAi5A1hx.js → report-reader-P41jUFxW.js} +1 -1
- package/web/dist/assets/{reports-C8NVgUwM.js → reports-C-Zop07b.js} +1 -1
- package/web/dist/assets/{resources-section-CcCHCo4b.js → resources-section-Cy0EShrb.js} +1 -1
- package/web/dist/assets/{run-header-Dpr7e1J3.js → run-header-Cd6Z_Juw.js} +1 -1
- package/web/dist/assets/session-context-section-BsT7MXjZ.js +119 -0
- package/web/dist/assets/{settings-agent-picker-DTDM4RXo.js → settings-agent-picker-B8jmxleN.js} +1 -1
- package/web/dist/assets/{settings-shell-CTuW5ilp.js → settings-shell-f9o6rKSB.js} +1 -1
- package/web/dist/assets/{sidebar-section-D9xKMCxo.js → sidebar-section-ekWNCGBw.js} +1 -1
- package/web/dist/assets/{skills-QSp2j0Ei.js → skills-DweafQfi.js} +1 -1
- package/web/dist/assets/{task-changes-C_1yQ3pc.js → task-changes-Db7mjsBc.js} +1 -1
- package/web/dist/assets/{task-commits-B156s4Br.js → task-commits-A0qKHFEp.js} +1 -1
- package/web/dist/assets/{task-files-DQyZkvNF.js → task-files-Cf4k3GXd.js} +1 -1
- package/web/dist/assets/{task-github-item-trHnGX_B.js → task-github-item-aab_QTS3.js} +1 -1
- package/web/dist/assets/{task-groups-ClNnAPRA.js → task-groups-Ziytm1Sm.js} +1 -1
- package/web/dist/assets/{task-thread-B4DPy4Lk.js → task-thread-Di1O-QIZ.js} +1 -1
- package/web/dist/assets/{tasks-table-CE_VVk0w.js → tasks-table-wTQZb7nJ.js} +1 -1
- package/web/dist/assets/{thread-state-BsUveC05.js → thread-state-BLpB8owZ.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-CtDcLIHc.js → use-hand-to-agent-state-Dkln0aUg.js} +1 -1
- package/web/dist/assets/{workflows-BQkr2ayW.js → workflows-D0FFSZRo.js} +1 -1
- package/web/dist/assets/{workspace-tools-aucXH9WE.js → workspace-tools-Bc-FDfxj.js} +1 -1
- package/web/dist/assets/{worktrees-section-A8b6TByx.js → worktrees-section-KHsxVu0L.js} +1 -1
- package/web/dist/index.html +8 -8
- package/web/dist/assets/queries-DRpvYgai.js +0 -1
- package/web/dist/assets/session-context-section-Ga1E-Y_8.js +0 -119
package/dist/server/server.d.ts
CHANGED
|
@@ -4188,12 +4188,21 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
4188
4188
|
"/session-context": {
|
|
4189
4189
|
$get: {
|
|
4190
4190
|
output: {
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4191
|
+
local: {
|
|
4192
|
+
path: string;
|
|
4193
|
+
exists: boolean;
|
|
4194
|
+
content: string;
|
|
4195
|
+
version: string | null;
|
|
4196
|
+
writable: boolean;
|
|
4197
|
+
readOnlyReason: string | null;
|
|
4198
|
+
};
|
|
4199
|
+
shared: {
|
|
4200
|
+
path: string;
|
|
4201
|
+
exists: boolean;
|
|
4202
|
+
content: string;
|
|
4203
|
+
tracked: boolean;
|
|
4204
|
+
unreadableReason: string | null;
|
|
4205
|
+
};
|
|
4197
4206
|
};
|
|
4198
4207
|
outputFormat: "json";
|
|
4199
4208
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -4211,8 +4220,10 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
4211
4220
|
}[];
|
|
4212
4221
|
blocks: {
|
|
4213
4222
|
id: string;
|
|
4223
|
+
source: 'built-in' | import("../session-context.ts").SessionContextRuleSource;
|
|
4214
4224
|
target: import("../session-context.ts").SessionContextRule['target'] | 'built-in' | null;
|
|
4215
4225
|
status: import("../session-context.ts").SessionContextReportStatus | 'not-for-role';
|
|
4226
|
+
overridesShared: boolean;
|
|
4216
4227
|
bytes: number | null;
|
|
4217
4228
|
reason: string | null;
|
|
4218
4229
|
sources: string[];
|
|
@@ -4236,12 +4247,21 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
4236
4247
|
"/session-context": {
|
|
4237
4248
|
$put: {
|
|
4238
4249
|
output: {
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4250
|
+
local: {
|
|
4251
|
+
path: string;
|
|
4252
|
+
exists: boolean;
|
|
4253
|
+
content: string;
|
|
4254
|
+
version: string | null;
|
|
4255
|
+
writable: boolean;
|
|
4256
|
+
readOnlyReason: string | null;
|
|
4257
|
+
};
|
|
4258
|
+
shared: {
|
|
4259
|
+
path: string;
|
|
4260
|
+
exists: boolean;
|
|
4261
|
+
content: string;
|
|
4262
|
+
tracked: boolean;
|
|
4263
|
+
unreadableReason: string | null;
|
|
4264
|
+
};
|
|
4245
4265
|
};
|
|
4246
4266
|
outputFormat: "json";
|
|
4247
4267
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -19397,9 +19417,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
19397
19417
|
status: 404 | 409;
|
|
19398
19418
|
input: {
|
|
19399
19419
|
param: {
|
|
19400
|
-
sha: string;
|
|
19401
|
-
} & {
|
|
19402
19420
|
id: string;
|
|
19421
|
+
} & {
|
|
19422
|
+
sha: string;
|
|
19403
19423
|
};
|
|
19404
19424
|
};
|
|
19405
19425
|
} | {
|
|
@@ -19428,9 +19448,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
19428
19448
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
19429
19449
|
input: {
|
|
19430
19450
|
param: {
|
|
19431
|
-
sha: string;
|
|
19432
|
-
} & {
|
|
19433
19451
|
id: string;
|
|
19452
|
+
} & {
|
|
19453
|
+
sha: string;
|
|
19434
19454
|
};
|
|
19435
19455
|
};
|
|
19436
19456
|
};
|
|
@@ -20910,12 +20930,21 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
20910
20930
|
"/session-context": {
|
|
20911
20931
|
$get: {
|
|
20912
20932
|
output: {
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
|
|
20916
|
-
|
|
20917
|
-
|
|
20918
|
-
|
|
20933
|
+
local: {
|
|
20934
|
+
path: string;
|
|
20935
|
+
exists: boolean;
|
|
20936
|
+
content: string;
|
|
20937
|
+
version: string | null;
|
|
20938
|
+
writable: boolean;
|
|
20939
|
+
readOnlyReason: string | null;
|
|
20940
|
+
};
|
|
20941
|
+
shared: {
|
|
20942
|
+
path: string;
|
|
20943
|
+
exists: boolean;
|
|
20944
|
+
content: string;
|
|
20945
|
+
tracked: boolean;
|
|
20946
|
+
unreadableReason: string | null;
|
|
20947
|
+
};
|
|
20919
20948
|
};
|
|
20920
20949
|
outputFormat: "json";
|
|
20921
20950
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -20933,8 +20962,10 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
20933
20962
|
}[];
|
|
20934
20963
|
blocks: {
|
|
20935
20964
|
id: string;
|
|
20965
|
+
source: 'built-in' | import("../session-context.ts").SessionContextRuleSource;
|
|
20936
20966
|
target: import("../session-context.ts").SessionContextRule['target'] | 'built-in' | null;
|
|
20937
20967
|
status: import("../session-context.ts").SessionContextReportStatus | 'not-for-role';
|
|
20968
|
+
overridesShared: boolean;
|
|
20938
20969
|
bytes: number | null;
|
|
20939
20970
|
reason: string | null;
|
|
20940
20971
|
sources: string[];
|
|
@@ -20958,12 +20989,21 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
20958
20989
|
"/session-context": {
|
|
20959
20990
|
$put: {
|
|
20960
20991
|
output: {
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
20965
|
-
|
|
20966
|
-
|
|
20992
|
+
local: {
|
|
20993
|
+
path: string;
|
|
20994
|
+
exists: boolean;
|
|
20995
|
+
content: string;
|
|
20996
|
+
version: string | null;
|
|
20997
|
+
writable: boolean;
|
|
20998
|
+
readOnlyReason: string | null;
|
|
20999
|
+
};
|
|
21000
|
+
shared: {
|
|
21001
|
+
path: string;
|
|
21002
|
+
exists: boolean;
|
|
21003
|
+
content: string;
|
|
21004
|
+
tracked: boolean;
|
|
21005
|
+
unreadableReason: string | null;
|
|
21006
|
+
};
|
|
20967
21007
|
};
|
|
20968
21008
|
outputFormat: "json";
|
|
20969
21009
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -36119,9 +36159,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
36119
36159
|
status: 404 | 409;
|
|
36120
36160
|
input: {
|
|
36121
36161
|
param: {
|
|
36122
|
-
sha: string;
|
|
36123
|
-
} & {
|
|
36124
36162
|
id: string;
|
|
36163
|
+
} & {
|
|
36164
|
+
sha: string;
|
|
36125
36165
|
};
|
|
36126
36166
|
};
|
|
36127
36167
|
} | {
|
|
@@ -36150,9 +36190,9 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
36150
36190
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
36151
36191
|
input: {
|
|
36152
36192
|
param: {
|
|
36153
|
-
sha: string;
|
|
36154
|
-
} & {
|
|
36155
36193
|
id: string;
|
|
36194
|
+
} & {
|
|
36195
|
+
sha: string;
|
|
36156
36196
|
};
|
|
36157
36197
|
};
|
|
36158
36198
|
};
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import type { ProjectApiEnv } from './server-types.ts';
|
|
2
2
|
/**
|
|
3
|
-
* Settings → Session context (hearsay-tools/squawk#4308). Writing `context.yaml`
|
|
4
|
-
* `settingsAdmin`: the file runs no host command, and its file includes
|
|
5
|
-
* (ADR 0055 gates only settings that persist host commands).
|
|
3
|
+
* Settings → Session context (hearsay-tools/squawk#4308, hearsay-tools/squawk#4341). Writing `context.local.yaml`
|
|
4
|
+
* needs no `settingsAdmin`: the file runs no host command, is gitignored, and its file includes
|
|
5
|
+
* stay inside the worktree (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
|
-
|
|
11
|
+
local: {
|
|
12
|
+
path: string;
|
|
13
|
+
exists: boolean;
|
|
14
|
+
content: string;
|
|
15
|
+
version: string | null;
|
|
16
|
+
writable: boolean;
|
|
17
|
+
readOnlyReason: string | null;
|
|
18
|
+
};
|
|
19
|
+
shared: {
|
|
20
|
+
path: string;
|
|
21
|
+
exists: boolean;
|
|
22
|
+
content: string;
|
|
23
|
+
tracked: boolean;
|
|
24
|
+
unreadableReason: string | null;
|
|
25
|
+
};
|
|
17
26
|
};
|
|
18
27
|
outputFormat: "json";
|
|
19
28
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
@@ -31,8 +40,10 @@ export declare function createSessionContextRoutes(): import("hono/hono-base").H
|
|
|
31
40
|
}[];
|
|
32
41
|
blocks: {
|
|
33
42
|
id: string;
|
|
43
|
+
source: 'built-in' | import("../session-context.ts").SessionContextRuleSource;
|
|
34
44
|
target: import("../session-context.ts").SessionContextRule['target'] | 'built-in' | null;
|
|
35
45
|
status: import("../session-context.ts").SessionContextReportStatus | 'not-for-role';
|
|
46
|
+
overridesShared: boolean;
|
|
36
47
|
bytes: number | null;
|
|
37
48
|
reason: string | null;
|
|
38
49
|
sources: string[];
|
|
@@ -56,12 +67,21 @@ export declare function createSessionContextRoutes(): import("hono/hono-base").H
|
|
|
56
67
|
"/session-context": {
|
|
57
68
|
$put: {
|
|
58
69
|
output: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
local: {
|
|
71
|
+
path: string;
|
|
72
|
+
exists: boolean;
|
|
73
|
+
content: string;
|
|
74
|
+
version: string | null;
|
|
75
|
+
writable: boolean;
|
|
76
|
+
readOnlyReason: string | null;
|
|
77
|
+
};
|
|
78
|
+
shared: {
|
|
79
|
+
path: string;
|
|
80
|
+
exists: boolean;
|
|
81
|
+
content: string;
|
|
82
|
+
tracked: boolean;
|
|
83
|
+
unreadableReason: string | null;
|
|
84
|
+
};
|
|
65
85
|
};
|
|
66
86
|
outputFormat: "json";
|
|
67
87
|
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 { readSessionContextState, writeSessionContextFile } from '../session-context-file.js';
|
|
5
5
|
import { jsonZodValidator } from './validators.js';
|
|
6
6
|
/**
|
|
7
|
-
* Settings → Session context (hearsay-tools/squawk#4308). Writing `context.yaml`
|
|
8
|
-
* `settingsAdmin`: the file runs no host command, and its file includes
|
|
9
|
-
* (ADR 0055 gates only settings that persist host commands).
|
|
7
|
+
* Settings → Session context (hearsay-tools/squawk#4308, hearsay-tools/squawk#4341). Writing `context.local.yaml`
|
|
8
|
+
* needs no `settingsAdmin`: the file runs no host command, is gitignored, and its file includes
|
|
9
|
+
* stay inside the worktree (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 readSessionContextState(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.state);
|
|
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,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,IAAI,EAAiB;SAC7B,GAAG,CAAC,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;SAElG,IAAI,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,kCAAkC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QAC5F,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,OAAO,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvH,CAAC,CAAC;SAED,GAAG,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC9E,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,GAAG,GAAG,MAAM,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7F,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7D,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function
|
|
1
|
+
import { type SessionContextState } from './contract/index.js';
|
|
2
|
+
export declare function readSessionContextState(projectRoot: string): Promise<SessionContextState>;
|
|
3
3
|
export type SessionContextWrite = {
|
|
4
4
|
ok: true;
|
|
5
|
-
|
|
5
|
+
state: SessionContextState;
|
|
6
6
|
} | {
|
|
7
7
|
ok: false;
|
|
8
8
|
status: 400 | 409 | 500;
|
|
@@ -1,16 +1,20 @@
|
|
|
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 } from './contract/index.js';
|
|
4
|
+
import { SESSION_CONTEXT_FILE_MAX_BYTES, } from './contract/index.js';
|
|
5
|
+
import { ensureDataGitignore } from './data-gitignore.js';
|
|
6
|
+
import { runGit } from './git-command.js';
|
|
5
7
|
import { fallbackProjectWriteError, readProjectPath } from './project-paths.js';
|
|
6
8
|
import { parseSessionContextText } from './session-context.js';
|
|
7
9
|
/**
|
|
8
|
-
* The cockpit's read
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* file
|
|
10
|
+
* The cockpit's read of both `context.yaml` (shared, read-only) and `context.local.yaml` (local,
|
|
11
|
+
* editable), and atomic write of `context.local.yaml` (hearsay-tools/squawk#4308, hearsay-tools/squawk#4341). Writing
|
|
12
|
+
* ensures `context.local.yaml` is gitignored so host edits never dirty `git status`. Fallback
|
|
13
|
+
* project data and symlinks stay read only so a remote user cannot redirect writes onto another
|
|
14
|
+
* file such as `config.json`.
|
|
13
15
|
*/
|
|
16
|
+
const SHARED_FILE = 'context.yaml';
|
|
17
|
+
const LOCAL_FILE = 'context.local.yaml';
|
|
14
18
|
function hashBytes(content) {
|
|
15
19
|
return createHash('sha256').update(content, 'utf8').digest('hex');
|
|
16
20
|
}
|
|
@@ -73,6 +77,15 @@ async function readCurrent(projectRoot, path) {
|
|
|
73
77
|
return { exists: true, unreadable: `it cannot be read (${error.code ?? 'error'})` };
|
|
74
78
|
}
|
|
75
79
|
}
|
|
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
|
+
}
|
|
76
89
|
function answer(projectRoot, path, current) {
|
|
77
90
|
const shown = relative(projectRoot, path);
|
|
78
91
|
const fallback = fallbackProjectWriteError(path);
|
|
@@ -90,14 +103,29 @@ function answer(projectRoot, path, current) {
|
|
|
90
103
|
writable: fallback === undefined, readOnlyReason: fallback ?? null,
|
|
91
104
|
};
|
|
92
105
|
}
|
|
93
|
-
|
|
94
|
-
const path = readProjectPath(projectRoot,
|
|
95
|
-
|
|
106
|
+
async function readSharedFile(projectRoot) {
|
|
107
|
+
const path = readProjectPath(projectRoot, SHARED_FILE);
|
|
108
|
+
const shown = relative(projectRoot, path);
|
|
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 };
|
|
96
124
|
}
|
|
97
125
|
/** One save at a time per file, so two saves over one version cannot both pass the check. */
|
|
98
126
|
const writing = new Map();
|
|
99
127
|
export function writeSessionContextFile(projectRoot, content, version) {
|
|
100
|
-
const path = readProjectPath(projectRoot,
|
|
128
|
+
const path = readProjectPath(projectRoot, LOCAL_FILE);
|
|
101
129
|
const previous = writing.get(path) ?? Promise.resolve();
|
|
102
130
|
const next = previous.then(() => writeChecked(projectRoot, path, content, version));
|
|
103
131
|
const settled = next.catch(() => undefined);
|
|
@@ -112,15 +140,16 @@ async function writeChecked(projectRoot, path, content, version) {
|
|
|
112
140
|
return { ok: false, status: 409, error: before.readOnlyReason ?? `${before.path} is read only` };
|
|
113
141
|
if (before.version !== version) {
|
|
114
142
|
const error = before.exists
|
|
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.';
|
|
143
|
+
? 'context.local.yaml changed on disk since you opened it. Show the disk version, or overwrite it.'
|
|
144
|
+
: 'context.local.yaml was deleted on disk since you opened it. Show the disk version, or overwrite it.';
|
|
117
145
|
return { ok: false, status: 409, error };
|
|
118
146
|
}
|
|
119
|
-
const first = parseSessionContextText(content).problems[0];
|
|
147
|
+
const first = parseSessionContextText(content, 'local', before.path).problems[0];
|
|
120
148
|
if (first) {
|
|
121
149
|
const where = first.line === null ? '' : `line ${first.line}: `;
|
|
122
|
-
return { ok: false, status: 400, error: `context.yaml has problems; fix them to save (${where}${first.message})` };
|
|
150
|
+
return { ok: false, status: 400, error: `context.local.yaml has problems; fix them to save (${where}${first.message})` };
|
|
123
151
|
}
|
|
152
|
+
ensureDataGitignore(projectRoot);
|
|
124
153
|
// The rename replaces the path itself, never a file a link points to: the check above refuses links.
|
|
125
154
|
const tmp = `${path}.hsq-tmp-${process.pid}-${randomUUID()}`;
|
|
126
155
|
try {
|
|
@@ -131,7 +160,7 @@ async function writeChecked(projectRoot, path, content, version) {
|
|
|
131
160
|
const staged = answer(projectRoot, path, await readCurrent(projectRoot, path));
|
|
132
161
|
if (staged.version !== version || !staged.writable) {
|
|
133
162
|
await rm(tmp, { force: true });
|
|
134
|
-
return { ok: false, status: 409, error: 'context.yaml changed on disk since you opened it. Show the disk version, or overwrite it.' };
|
|
163
|
+
return { ok: false, status: 409, error: 'context.local.yaml changed on disk since you opened it. Show the disk version, or overwrite it.' };
|
|
135
164
|
}
|
|
136
165
|
await rename(tmp, path);
|
|
137
166
|
}
|
|
@@ -139,6 +168,6 @@ async function writeChecked(projectRoot, path, content, version) {
|
|
|
139
168
|
await rm(tmp, { force: true });
|
|
140
169
|
return { ok: false, status: 500, error: error.message };
|
|
141
170
|
}
|
|
142
|
-
return { ok: true,
|
|
171
|
+
return { ok: true, state: await readSessionContextState(projectRoot) };
|
|
143
172
|
}
|
|
144
173
|
//# 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,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,EACL,8BAA8B,GAI/B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE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AC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC,WAAW,CAAC,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -9,8 +9,10 @@
|
|
|
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
|
+
/** Shared project rules, relative to the project root. Optional: absent means no shared 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";
|
|
14
16
|
/** The built-in handoff block's id; a custom rule cannot take it. */
|
|
15
17
|
export declare const HANDOFF_CONTEXT_ID = "handoff";
|
|
16
18
|
/** Divides the prefix from the opening message. */
|
|
@@ -19,10 +21,14 @@ export declare const SESSION_CONTEXT_SEPARATOR = "\n\n---\n\n";
|
|
|
19
21
|
export declare const SESSION_CONTEXT_VARIABLES: readonly ['task', 'run.id', 'role', 'workflow.name', 'step.id', 'project.root', 'worktree.root', 'handoff.path'];
|
|
20
22
|
export type SessionContextVariable = typeof SESSION_CONTEXT_VARIABLES[number];
|
|
21
23
|
export type SessionContextRole = 'parent' | 'worker';
|
|
24
|
+
export type SessionContextRuleSource = 'shared' | 'local';
|
|
22
25
|
export interface SessionContextRule {
|
|
23
26
|
id: string;
|
|
24
27
|
target: 'parent' | 'worker' | 'both';
|
|
25
28
|
template: string;
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
source: SessionContextRuleSource;
|
|
31
|
+
overridesShared?: boolean;
|
|
26
32
|
}
|
|
27
33
|
export declare const SESSION_CONTEXT_REPORT_STATUSES: readonly ['applied', 'skipped'];
|
|
28
34
|
export type SessionContextReportStatus = (typeof SESSION_CONTEXT_REPORT_STATUSES)[number];
|
|
@@ -44,9 +50,9 @@ export interface SessionContext {
|
|
|
44
50
|
reports: SessionContextReport[];
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
|
-
* Read and validate the project's
|
|
48
|
-
*
|
|
49
|
-
* a bad, duplicate or reserved rule skips that rule alone.
|
|
53
|
+
* Read and validate the project's shared (`context.yaml`) and local (`context.local.yaml`) rules.
|
|
54
|
+
* A missing file is no rules and no warning; a file that cannot be read or parsed skips only its
|
|
55
|
+
* own layer with one report; a bad, duplicate or reserved rule skips that rule alone.
|
|
50
56
|
*/
|
|
51
57
|
export declare function loadSessionContextRules(projectRoot: string): {
|
|
52
58
|
rules: SessionContextRule[];
|
|
@@ -67,10 +73,10 @@ export interface ParsedSessionContext {
|
|
|
67
73
|
problems: SessionContextProblem[];
|
|
68
74
|
}
|
|
69
75
|
/**
|
|
70
|
-
* Parse `context.yaml` text once for both readers: a launch takes `rules`
|
|
71
|
-
* cockpit editor takes `problems`, each with the line it starts on.
|
|
76
|
+
* Parse a `context.yaml` or `context.local.yaml` text once for both readers: a launch takes `rules`
|
|
77
|
+
* and `reports`, the cockpit editor takes `problems`, each with the line it starts on.
|
|
72
78
|
*/
|
|
73
|
-
export declare function parseSessionContextText(text: string): ParsedSessionContext;
|
|
79
|
+
export declare function parseSessionContextText(text: string, source?: SessionContextRuleSource, sourcePath?: string): ParsedSessionContext;
|
|
74
80
|
export interface SessionContextInput {
|
|
75
81
|
projectRoot: string;
|
|
76
82
|
/** The receiving session's working directory: where `{{file:…}}` paths resolve. */
|
|
@@ -85,9 +91,11 @@ export declare function buildSessionContext(input: SessionContextInput): Session
|
|
|
85
91
|
export declare const SESSION_CONTEXT_PREVIEW_TEXT_CHARS = 2000;
|
|
86
92
|
export interface SessionContextPreviewBlock {
|
|
87
93
|
id: string;
|
|
94
|
+
source: 'built-in' | SessionContextRuleSource;
|
|
88
95
|
/** `built-in` for the handoff; null for an entry the file could not name a target for. */
|
|
89
96
|
target: SessionContextRule['target'] | 'built-in' | null;
|
|
90
97
|
status: SessionContextReportStatus | 'not-for-role';
|
|
98
|
+
overridesShared: boolean;
|
|
91
99
|
bytes: number | null;
|
|
92
100
|
reason: string | null;
|
|
93
101
|
sources: string[];
|
|
@@ -102,8 +110,9 @@ export interface SessionContextPreview {
|
|
|
102
110
|
limitBytes: number;
|
|
103
111
|
}
|
|
104
112
|
/**
|
|
105
|
-
* Render
|
|
106
|
-
*
|
|
113
|
+
* Render the combined launch output for one role: sample handoff, shared `context.yaml` on disk
|
|
114
|
+
* in `projectRoot`, and the unsaved `context.local.yaml` draft `content`. `problems` lists issues
|
|
115
|
+
* in the local draft only, so broken shared YAML does not block fixing or saving local rules.
|
|
107
116
|
*/
|
|
108
117
|
export declare function previewSessionContext(options: {
|
|
109
118
|
projectRoot: string;
|