@hearsay-tools/squawk 0.18.0-dev.8555 → 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/server/runs-routes.d.ts +16 -16
- package/dist/server/server.d.ts +64 -24
- 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/contract/index.js
CHANGED
|
@@ -4020,10 +4020,11 @@ var setAgentConfigInputSchema = z30.object({
|
|
|
4020
4020
|
import { z as z31 } from "zod";
|
|
4021
4021
|
var SESSION_CONTEXT_FILE_MAX_BYTES = 256 * 1024;
|
|
4022
4022
|
var fileContentSchema = z31.string().refine((text) => utf8Bytes(text) <= SESSION_CONTEXT_FILE_MAX_BYTES, {
|
|
4023
|
-
error: `context.yaml must be at most ${SESSION_CONTEXT_FILE_MAX_BYTES} bytes`
|
|
4023
|
+
error: `context.local.yaml must be at most ${SESSION_CONTEXT_FILE_MAX_BYTES} bytes`
|
|
4024
4024
|
});
|
|
4025
|
+
var sessionContextSourceSchema = z31.enum(["built-in", "shared", "local"]);
|
|
4025
4026
|
var sessionContextFileSchema = z31.object({
|
|
4026
|
-
/** Relative to the project root: `.ai/squawk/context.yaml` or `.ai/cezar/context.yaml`. */
|
|
4027
|
+
/** Relative to the project root: `.ai/squawk/context.local.yaml` or `.ai/cezar/context.local.yaml`. */
|
|
4027
4028
|
path: z31.string(),
|
|
4028
4029
|
exists: z31.boolean(),
|
|
4029
4030
|
content: z31.string(),
|
|
@@ -4033,6 +4034,20 @@ var sessionContextFileSchema = z31.object({
|
|
|
4033
4034
|
writable: z31.boolean(),
|
|
4034
4035
|
readOnlyReason: z31.string().nullable()
|
|
4035
4036
|
});
|
|
4037
|
+
var sessionContextSharedFileSchema = z31.object({
|
|
4038
|
+
/** Relative to the project root: `.ai/squawk/context.yaml` or `.ai/cezar/context.yaml`. */
|
|
4039
|
+
path: z31.string(),
|
|
4040
|
+
exists: z31.boolean(),
|
|
4041
|
+
content: z31.string(),
|
|
4042
|
+
/** True when Git tracks this file in the repository index. */
|
|
4043
|
+
tracked: z31.boolean(),
|
|
4044
|
+
/** Non-null when the file cannot be read as UTF-8 text (e.g. symlink, binary, oversized). */
|
|
4045
|
+
unreadableReason: z31.string().nullable()
|
|
4046
|
+
});
|
|
4047
|
+
var sessionContextStateSchema = z31.object({
|
|
4048
|
+
local: sessionContextFileSchema,
|
|
4049
|
+
shared: sessionContextSharedFileSchema
|
|
4050
|
+
});
|
|
4036
4051
|
var setSessionContextSchema = z31.object({
|
|
4037
4052
|
content: fileContentSchema,
|
|
4038
4053
|
version: z31.string().nullable()
|
|
@@ -4049,9 +4064,12 @@ var sessionContextProblemSchema = z31.object({
|
|
|
4049
4064
|
});
|
|
4050
4065
|
var sessionContextPreviewBlockSchema = z31.object({
|
|
4051
4066
|
id: z31.string(),
|
|
4067
|
+
source: sessionContextSourceSchema,
|
|
4052
4068
|
/** `built-in` for the handoff block; null when the file names no target for the entry. */
|
|
4053
4069
|
target: z31.enum(["built-in", "parent", "worker", "both"]).nullable(),
|
|
4054
4070
|
status: z31.enum(["applied", "skipped", "not-for-role"]),
|
|
4071
|
+
/** True when a local rule replaced or muted a shared rule with the same id. */
|
|
4072
|
+
overridesShared: z31.boolean(),
|
|
4055
4073
|
bytes: z31.number().nullable(),
|
|
4056
4074
|
reason: z31.string().nullable(),
|
|
4057
4075
|
sources: z31.array(z31.string()),
|
|
@@ -6921,6 +6939,9 @@ export {
|
|
|
6921
6939
|
sessionContextPreviewSchema,
|
|
6922
6940
|
sessionContextProblemSchema,
|
|
6923
6941
|
sessionContextRoleSchema,
|
|
6942
|
+
sessionContextSharedFileSchema,
|
|
6943
|
+
sessionContextSourceSchema,
|
|
6944
|
+
sessionContextStateSchema,
|
|
6924
6945
|
sessionRunner,
|
|
6925
6946
|
setAgentConfigInputSchema,
|
|
6926
6947
|
setAgentConfigSchema,
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
* Settings → Session context (hearsay-tools/squawk#4308): read
|
|
4
|
-
* `context.yaml`
|
|
5
|
-
* `GET/PUT /session-context` and `POST /session-context/preview`.
|
|
3
|
+
* Settings → Session context (hearsay-tools/squawk#4308, hearsay-tools/squawk#4341): read shared
|
|
4
|
+
* `context.yaml` and local `context.local.yaml`, preview their combined launch output, and save
|
|
5
|
+
* `context.local.yaml` through `GET/PUT /session-context` and `POST /session-context/preview`.
|
|
6
6
|
*/
|
|
7
|
-
/** The largest
|
|
7
|
+
/** The largest context YAML file a launch reads, in UTF-8 bytes. The editor cannot save a larger one. */
|
|
8
8
|
export declare const SESSION_CONTEXT_FILE_MAX_BYTES: number;
|
|
9
|
-
|
|
9
|
+
export declare const sessionContextSourceSchema: z.ZodEnum<{
|
|
10
|
+
"built-in": "built-in";
|
|
11
|
+
local: "local";
|
|
12
|
+
shared: "shared";
|
|
13
|
+
}>;
|
|
14
|
+
export type SessionContextSource = z.infer<typeof sessionContextSourceSchema>;
|
|
15
|
+
/** The editable local file (`context.local.yaml`) as it is on disk, with its stale-write token. */
|
|
10
16
|
export declare const sessionContextFileSchema: z.ZodObject<{
|
|
11
17
|
path: z.ZodString;
|
|
12
18
|
exists: z.ZodBoolean;
|
|
@@ -16,7 +22,35 @@ export declare const sessionContextFileSchema: z.ZodObject<{
|
|
|
16
22
|
readOnlyReason: z.ZodNullable<z.ZodString>;
|
|
17
23
|
}, z.core.$strip>;
|
|
18
24
|
export type SessionContextFile = z.infer<typeof sessionContextFileSchema>;
|
|
19
|
-
/**
|
|
25
|
+
/** The shared repository file (`context.yaml`), shown read-only in Project Settings. */
|
|
26
|
+
export declare const sessionContextSharedFileSchema: z.ZodObject<{
|
|
27
|
+
path: z.ZodString;
|
|
28
|
+
exists: z.ZodBoolean;
|
|
29
|
+
content: z.ZodString;
|
|
30
|
+
tracked: z.ZodBoolean;
|
|
31
|
+
unreadableReason: z.ZodNullable<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type SessionContextSharedFile = z.infer<typeof sessionContextSharedFileSchema>;
|
|
34
|
+
/** `GET /session-context` and the `PUT` answer: both local and shared layers as they stand on disk. */
|
|
35
|
+
export declare const sessionContextStateSchema: z.ZodObject<{
|
|
36
|
+
local: z.ZodObject<{
|
|
37
|
+
path: z.ZodString;
|
|
38
|
+
exists: z.ZodBoolean;
|
|
39
|
+
content: z.ZodString;
|
|
40
|
+
version: z.ZodNullable<z.ZodString>;
|
|
41
|
+
writable: z.ZodBoolean;
|
|
42
|
+
readOnlyReason: z.ZodNullable<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
shared: z.ZodObject<{
|
|
45
|
+
path: z.ZodString;
|
|
46
|
+
exists: z.ZodBoolean;
|
|
47
|
+
content: z.ZodString;
|
|
48
|
+
tracked: z.ZodBoolean;
|
|
49
|
+
unreadableReason: z.ZodNullable<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type SessionContextState = z.infer<typeof sessionContextStateSchema>;
|
|
53
|
+
/** `PUT /session-context`. Saves `context.local.yaml`; `version` is the token the editor read (null creates it). */
|
|
20
54
|
export declare const setSessionContextSchema: z.ZodObject<{
|
|
21
55
|
content: z.ZodString;
|
|
22
56
|
version: z.ZodNullable<z.ZodString>;
|
|
@@ -27,7 +61,7 @@ export declare const sessionContextRoleSchema: z.ZodEnum<{
|
|
|
27
61
|
worker: "worker";
|
|
28
62
|
}>;
|
|
29
63
|
export type SessionContextRole = z.infer<typeof sessionContextRoleSchema>;
|
|
30
|
-
/** `POST /session-context/preview`: render
|
|
64
|
+
/** `POST /session-context/preview`: render the combined launch output for one role with an unsaved local draft. */
|
|
31
65
|
export declare const sessionContextPreviewRequestSchema: z.ZodObject<{
|
|
32
66
|
content: z.ZodString;
|
|
33
67
|
role: z.ZodEnum<{
|
|
@@ -36,7 +70,7 @@ export declare const sessionContextPreviewRequestSchema: z.ZodObject<{
|
|
|
36
70
|
}>;
|
|
37
71
|
}, z.core.$strip>;
|
|
38
72
|
export type SessionContextPreviewRequest = z.infer<typeof sessionContextPreviewRequestSchema>;
|
|
39
|
-
/** One thing the draft must fix before it saves. `line` and `rule` count from 1. */
|
|
73
|
+
/** One thing the local draft must fix before it saves. `line` and `rule` count from 1. */
|
|
40
74
|
export declare const sessionContextProblemSchema: z.ZodObject<{
|
|
41
75
|
line: z.ZodNullable<z.ZodNumber>;
|
|
42
76
|
rule: z.ZodNullable<z.ZodNumber>;
|
|
@@ -45,6 +79,11 @@ export declare const sessionContextProblemSchema: z.ZodObject<{
|
|
|
45
79
|
export type SessionContextProblem = z.infer<typeof sessionContextProblemSchema>;
|
|
46
80
|
export declare const sessionContextPreviewBlockSchema: z.ZodObject<{
|
|
47
81
|
id: z.ZodString;
|
|
82
|
+
source: z.ZodEnum<{
|
|
83
|
+
"built-in": "built-in";
|
|
84
|
+
local: "local";
|
|
85
|
+
shared: "shared";
|
|
86
|
+
}>;
|
|
48
87
|
target: z.ZodNullable<z.ZodEnum<{
|
|
49
88
|
both: "both";
|
|
50
89
|
"built-in": "built-in";
|
|
@@ -56,6 +95,7 @@ export declare const sessionContextPreviewBlockSchema: z.ZodObject<{
|
|
|
56
95
|
"not-for-role": "not-for-role";
|
|
57
96
|
skipped: "skipped";
|
|
58
97
|
}>;
|
|
98
|
+
overridesShared: z.ZodBoolean;
|
|
59
99
|
bytes: z.ZodNullable<z.ZodNumber>;
|
|
60
100
|
reason: z.ZodNullable<z.ZodString>;
|
|
61
101
|
sources: z.ZodArray<z.ZodString>;
|
|
@@ -71,6 +111,11 @@ export declare const sessionContextPreviewSchema: z.ZodObject<{
|
|
|
71
111
|
}, z.core.$strip>>;
|
|
72
112
|
blocks: z.ZodArray<z.ZodObject<{
|
|
73
113
|
id: z.ZodString;
|
|
114
|
+
source: z.ZodEnum<{
|
|
115
|
+
"built-in": "built-in";
|
|
116
|
+
local: "local";
|
|
117
|
+
shared: "shared";
|
|
118
|
+
}>;
|
|
74
119
|
target: z.ZodNullable<z.ZodEnum<{
|
|
75
120
|
both: "both";
|
|
76
121
|
"built-in": "built-in";
|
|
@@ -82,6 +127,7 @@ export declare const sessionContextPreviewSchema: z.ZodObject<{
|
|
|
82
127
|
"not-for-role": "not-for-role";
|
|
83
128
|
skipped: "skipped";
|
|
84
129
|
}>;
|
|
130
|
+
overridesShared: z.ZodBoolean;
|
|
85
131
|
bytes: z.ZodNullable<z.ZodNumber>;
|
|
86
132
|
reason: z.ZodNullable<z.ZodString>;
|
|
87
133
|
sources: z.ZodArray<z.ZodString>;
|
package/dist/data-gitignore.js
CHANGED
|
@@ -44,6 +44,7 @@ export function ensureDataGitignore(repoRoot) {
|
|
|
44
44
|
'automations.reclaim*/',
|
|
45
45
|
'automation-state.lock',
|
|
46
46
|
'automation-state.reclaim*/',
|
|
47
|
+
'context.local.yaml', // host-local session context overrides (hearsay-tools/squawk#4341)
|
|
47
48
|
];
|
|
48
49
|
try {
|
|
49
50
|
// A tracked copy left in the fallback directory awaits the user's `git mv`: a new file at its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-gitignore.js","sourceRoot":"","sources":["../src/data-gitignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IAC3B,IAAI,mBAAmB,CAAC,KAAK,CAAC;QAAE,OAAO;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG;QACb,WAAW;QACX,eAAe;QACf,0BAA0B,EAAE,gEAAgE;QAC5F,wBAAwB,EAAE,gEAAgE;QA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,GAAG,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzI,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;AACH,CAAC"}
|
|
@@ -12273,20 +12273,20 @@ export declare function createRunsRoutes(deps: RunsRouteDeps): import("hono/hono
|
|
|
12273
12273
|
} & {
|
|
12274
12274
|
"/runs/:id/handoff": {
|
|
12275
12275
|
$get: {
|
|
12276
|
-
output:
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
outputFormat: "json";
|
|
12280
|
-
status: 404;
|
|
12276
|
+
output: string;
|
|
12277
|
+
outputFormat: "text";
|
|
12278
|
+
status: 200;
|
|
12281
12279
|
input: {
|
|
12282
12280
|
param: {
|
|
12283
12281
|
id: string;
|
|
12284
12282
|
};
|
|
12285
12283
|
};
|
|
12286
12284
|
} | {
|
|
12287
|
-
output:
|
|
12288
|
-
|
|
12289
|
-
|
|
12285
|
+
output: {
|
|
12286
|
+
error: string;
|
|
12287
|
+
};
|
|
12288
|
+
outputFormat: "json";
|
|
12289
|
+
status: 404;
|
|
12290
12290
|
input: {
|
|
12291
12291
|
param: {
|
|
12292
12292
|
id: string;
|
|
@@ -12324,20 +12324,20 @@ export declare function createRunsRoutes(deps: RunsRouteDeps): import("hono/hono
|
|
|
12324
12324
|
} & {
|
|
12325
12325
|
"/runs/:id/diff": {
|
|
12326
12326
|
$get: {
|
|
12327
|
-
output:
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
outputFormat: "json";
|
|
12331
|
-
status: 404 | 409;
|
|
12327
|
+
output: string;
|
|
12328
|
+
outputFormat: "text";
|
|
12329
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
12332
12330
|
input: {
|
|
12333
12331
|
param: {
|
|
12334
12332
|
id: string;
|
|
12335
12333
|
};
|
|
12336
12334
|
};
|
|
12337
12335
|
} | {
|
|
12338
|
-
output:
|
|
12339
|
-
|
|
12340
|
-
|
|
12336
|
+
output: {
|
|
12337
|
+
error: string;
|
|
12338
|
+
};
|
|
12339
|
+
outputFormat: "json";
|
|
12340
|
+
status: 404 | 409;
|
|
12341
12341
|
input: {
|
|
12342
12342
|
param: {
|
|
12343
12343
|
id: string;
|
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;
|
|
@@ -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;
|
|
@@ -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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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
|