ctxr-cli 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/publish-check.d.ts.map +1 -1
- package/dist/commands/publish-check.js +8 -0
- package/dist/commands/publish-check.js.map +1 -1
- package/dist/commands/publish-new.d.ts.map +1 -1
- package/dist/commands/publish-new.js +15 -0
- package/dist/commands/publish-new.js.map +1 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +33 -11
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +9 -1
- package/dist/commands/session-start.js.map +1 -1
- package/dist/commands/source-check.d.ts.map +1 -1
- package/dist/commands/source-check.js +28 -3
- package/dist/commands/source-check.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +7 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/verify.d.ts +11 -2
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +86 -5
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/version.d.ts +31 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +87 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/config/defaults.d.ts +12 -2
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +9 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/load.d.ts +2 -2
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +13 -3
- package/dist/config/load.js.map +1 -1
- package/dist/config/render.d.ts +0 -6
- package/dist/config/render.d.ts.map +1 -1
- package/dist/config/render.js +4 -27
- package/dist/config/render.js.map +1 -1
- package/dist/config/schema.d.ts +17 -66
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +59 -111
- package/dist/config/schema.js.map +1 -1
- package/dist/core/browse/nav.d.ts.map +1 -1
- package/dist/core/browse/nav.js +4 -1
- package/dist/core/browse/nav.js.map +1 -1
- package/dist/core/browse/preferences.d.ts +26 -0
- package/dist/core/browse/preferences.d.ts.map +1 -0
- package/dist/core/browse/preferences.js +74 -0
- package/dist/core/browse/preferences.js.map +1 -0
- package/dist/core/browse/routes.d.ts +10 -8
- package/dist/core/browse/routes.d.ts.map +1 -1
- package/dist/core/browse/routes.js +113 -24
- package/dist/core/browse/routes.js.map +1 -1
- package/dist/core/browse/templates.d.ts +14 -4
- package/dist/core/browse/templates.d.ts.map +1 -1
- package/dist/core/browse/templates.js +22 -4
- package/dist/core/browse/templates.js.map +1 -1
- package/dist/core/checks/harness-portability-checks.d.ts +21 -0
- package/dist/core/checks/harness-portability-checks.d.ts.map +1 -1
- package/dist/core/checks/harness-portability-checks.js +46 -1
- package/dist/core/checks/harness-portability-checks.js.map +1 -1
- package/dist/core/checks/integrity-checks.d.ts +0 -2
- package/dist/core/checks/integrity-checks.d.ts.map +1 -1
- package/dist/core/checks/integrity-checks.js +2 -27
- package/dist/core/checks/integrity-checks.js.map +1 -1
- package/dist/core/command.d.ts +6 -0
- package/dist/core/command.d.ts.map +1 -1
- package/dist/core/env.d.ts +5 -0
- package/dist/core/env.d.ts.map +1 -1
- package/dist/core/env.js +3 -0
- package/dist/core/env.js.map +1 -1
- package/dist/core/environment/probe.d.ts +12 -0
- package/dist/core/environment/probe.d.ts.map +1 -0
- package/dist/core/environment/probe.js +36 -0
- package/dist/core/environment/probe.js.map +1 -0
- package/dist/core/errors.d.ts +16 -3
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +41 -15
- package/dist/core/errors.js.map +1 -1
- package/dist/core/git/worktree.d.ts +22 -0
- package/dist/core/git/worktree.d.ts.map +1 -1
- package/dist/core/git/worktree.js +34 -0
- package/dist/core/git/worktree.js.map +1 -1
- package/dist/core/harness/isolated-run.d.ts +52 -0
- package/dist/core/harness/isolated-run.d.ts.map +1 -0
- package/dist/core/harness/isolated-run.js +100 -0
- package/dist/core/harness/isolated-run.js.map +1 -0
- package/dist/core/install-kind.d.ts +25 -0
- package/dist/core/install-kind.d.ts.map +1 -0
- package/dist/core/install-kind.js +56 -0
- package/dist/core/install-kind.js.map +1 -0
- package/dist/core/publish/script-check.d.ts +5 -2
- package/dist/core/publish/script-check.d.ts.map +1 -1
- package/dist/core/publish/script-check.js +5 -2
- package/dist/core/publish/script-check.js.map +1 -1
- package/dist/core/registry.d.ts +40 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +55 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/root.d.ts +11 -5
- package/dist/core/root.d.ts.map +1 -1
- package/dist/core/root.js +20 -8
- package/dist/core/root.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +7 -0
- package/dist/core/skills.js.map +1 -1
- package/dist/core/version-check.d.ts +63 -0
- package/dist/core/version-check.d.ts.map +1 -0
- package/dist/core/version-check.js +181 -0
- package/dist/core/version-check.js.map +1 -0
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +38 -16
- package/dist/run.js.map +1 -1
- package/dist/version.d.ts +8 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +8 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/templates/agents/canonical.md +1 -1
- package/templates/serve/shell.html +16 -2
- package/templates/serve/style.css +145 -3
- package/templates/skills/ctxr-session-lifecycle.md +20 -0
- package/templates/skills/ctxr-upgrade.md +44 -0
- package/dist/commands/migrate.d.ts +0 -30
- package/dist/commands/migrate.d.ts.map +0 -1
- package/dist/commands/migrate.js +0 -56
- package/dist/commands/migrate.js.map +0 -1
- package/dist/core/migrations/add-explanation-craft-skill.d.ts +0 -26
- package/dist/core/migrations/add-explanation-craft-skill.d.ts.map +0 -1
- package/dist/core/migrations/add-explanation-craft-skill.js +0 -94
- package/dist/core/migrations/add-explanation-craft-skill.js.map +0 -1
- package/dist/core/migrations/archive-destination-from-taxonomy.d.ts +0 -35
- package/dist/core/migrations/archive-destination-from-taxonomy.d.ts.map +0 -1
- package/dist/core/migrations/archive-destination-from-taxonomy.js +0 -109
- package/dist/core/migrations/archive-destination-from-taxonomy.js.map +0 -1
- package/dist/core/migrations/config-defaults-as-the-convention.d.ts +0 -21
- package/dist/core/migrations/config-defaults-as-the-convention.d.ts.map +0 -1
- package/dist/core/migrations/config-defaults-as-the-convention.js +0 -54
- package/dist/core/migrations/config-defaults-as-the-convention.js.map +0 -1
- package/dist/core/migrations/drop-access-axes.d.ts +0 -24
- package/dist/core/migrations/drop-access-axes.d.ts.map +0 -1
- package/dist/core/migrations/drop-access-axes.js +0 -54
- package/dist/core/migrations/drop-access-axes.js.map +0 -1
- package/dist/core/migrations/drop-forge-and-workspaces-external.d.ts +0 -19
- package/dist/core/migrations/drop-forge-and-workspaces-external.d.ts.map +0 -1
- package/dist/core/migrations/drop-forge-and-workspaces-external.js +0 -49
- package/dist/core/migrations/drop-forge-and-workspaces-external.js.map +0 -1
- package/dist/core/migrations/registry.d.ts +0 -16
- package/dist/core/migrations/registry.d.ts.map +0 -1
- package/dist/core/migrations/registry.js +0 -34
- package/dist/core/migrations/registry.js.map +0 -1
- package/dist/core/migrations/rename-conventions-path.d.ts +0 -26
- package/dist/core/migrations/rename-conventions-path.d.ts.map +0 -1
- package/dist/core/migrations/rename-conventions-path.js +0 -86
- package/dist/core/migrations/rename-conventions-path.js.map +0 -1
- package/dist/core/migrations/rename-procedures-path.d.ts +0 -17
- package/dist/core/migrations/rename-procedures-path.d.ts.map +0 -1
- package/dist/core/migrations/rename-procedures-path.js +0 -45
- package/dist/core/migrations/rename-procedures-path.js.map +0 -1
- package/dist/core/migrations/retain-captures-as-provenance.d.ts +0 -22
- package/dist/core/migrations/retain-captures-as-provenance.d.ts.map +0 -1
- package/dist/core/migrations/retain-captures-as-provenance.js +0 -133
- package/dist/core/migrations/retain-captures-as-provenance.js.map +0 -1
- package/dist/core/migrations/types.d.ts +0 -27
- package/dist/core/migrations/types.d.ts.map +0 -1
- package/dist/core/migrations/types.js +0 -2
- package/dist/core/migrations/types.js.map +0 -1
package/dist/config/schema.d.ts
CHANGED
|
@@ -3,56 +3,21 @@ import { z } from 'zod';
|
|
|
3
3
|
* store-lifecycle spec: schema_version versions STORE STATE (config shape +
|
|
4
4
|
* note frontmatter conventions) — a monotonic integer independent of the npm
|
|
5
5
|
* package version — not "what this CLI release happens to be."
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Bumped to 2 by the visibility-field key rename migration (store-lifecycle
|
|
9
|
-
* spec task 9.2). Both that field and the config key naming it were removed
|
|
10
|
-
* at schema 7 (see below); the migration survives only to keep the 1 -> 2
|
|
11
|
-
* step in the chain intact.
|
|
12
|
-
*
|
|
13
|
-
* Bumped to 3 by the procedures-to-skills key rename migration
|
|
14
|
-
* (rename-procedures-to-skills, 0003-rename-procedures-path-to-skills):
|
|
15
|
-
* `harness.procedures_path` -> `harness.skills_path`. HarnessSchema's
|
|
16
|
-
* transform accepts the old key through this version so an unmigrated
|
|
17
|
-
* store still loads (see schema.ts's HarnessSchema comment).
|
|
18
6
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* (vendor-explanation-craft-skill, 0007-add-explanation-craft-skill), which
|
|
27
|
-
* pins its own local SCHEMA_VERSION and is unaffected by later bumps here.
|
|
7
|
+
* retire-store-migrations: contexture ships no migration mechanism, so this
|
|
8
|
+
* number is a gate rather than a starting point. `readConfig` refuses any
|
|
9
|
+
* store whose recorded version is not exactly this one, in either direction:
|
|
10
|
+
* a newer store because this release cannot know its shape, an older one
|
|
11
|
+
* because this release no longer reads that shape and offers nothing that
|
|
12
|
+
* would bring it forward. A release that changes the store's shape bumps this
|
|
13
|
+
* and documents the one-time fixup in its release notes.
|
|
28
14
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* an older store — `noUnrecognizedConfigKeysCheck` derives from this
|
|
34
|
-
* schema's shape, so an unmigrated store fails `doctor` on the three stale
|
|
35
|
-
* keys until `ctxr migrate` drops them, exactly as `identity` did when
|
|
36
|
-
* remove-agent-identity retired it.
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* Bumped to 9 by the capture-tier change (retain-captures-as-provenance,
|
|
40
|
-
* retain-captures-as-provenance): `ingest.capture_root` is added and
|
|
41
|
-
* `ingest.inbox_path`'s shipped default moves inside it. IngestSchema accepts
|
|
42
|
-
* a config with no `capture_root` so an unmigrated store still loads —
|
|
43
|
-
* `ctxr migrate` has to be able to read the file it is about to rewrite —
|
|
44
|
-
* and skips the nesting rule for exactly that case.
|
|
15
|
+
* It stayed at 10 through that retirement on purpose: nothing about a
|
|
16
|
+
* conforming store's shape changed. What was dropped were superseded INPUT
|
|
17
|
+
* spellings that no store at 10 has ever written, since `renderStoreConfig`
|
|
18
|
+
* only ever emitted the current names.
|
|
45
19
|
*/
|
|
46
20
|
export declare const SUPPORTED_SCHEMA_VERSION = 10;
|
|
47
|
-
/** The version at which the capture tier became part of the store's shape, and its nesting rule enforceable. */
|
|
48
|
-
export declare const CAPTURE_TIER_SCHEMA_VERSION = 9;
|
|
49
|
-
/**
|
|
50
|
-
* Bumped to 10 by config-defaults-as-the-convention: every convention key now
|
|
51
|
-
* carries its shipped default here, and a written config omits what it agrees
|
|
52
|
-
* with. Nothing about the shape got stricter — the bump exists so the pruning
|
|
53
|
-
* migration has a `schema_version <` predicate to decide it still has work,
|
|
54
|
-
* the same way every migration in this repo does.
|
|
55
|
-
*/
|
|
56
21
|
export declare const TaxonomyLayerSchema: z.ZodObject<{
|
|
57
22
|
name: z.ZodString;
|
|
58
23
|
path: z.ZodString;
|
|
@@ -125,6 +90,10 @@ export declare const StoreConfigSchema: z.ZodObject<{
|
|
|
125
90
|
skills: z.ZodPrefault<z.ZodObject<{
|
|
126
91
|
vendored: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
127
92
|
}, z.core.$strip>>;
|
|
93
|
+
update_check: z.ZodPrefault<z.ZodObject<{
|
|
94
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
95
|
+
ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
96
|
+
}, z.core.$strip>>;
|
|
128
97
|
ingest: z.ZodPrefault<z.ZodObject<{
|
|
129
98
|
inbox_path: z.ZodDefault<z.ZodString>;
|
|
130
99
|
capture_root: z.ZodDefault<z.ZodString>;
|
|
@@ -132,7 +101,6 @@ export declare const StoreConfigSchema: z.ZodObject<{
|
|
|
132
101
|
}, z.core.$strip>>;
|
|
133
102
|
organize: z.ZodPipe<z.ZodObject<{
|
|
134
103
|
archive_destination: z.ZodOptional<z.ZodString>;
|
|
135
|
-
archive_path: z.ZodOptional<z.ZodString>;
|
|
136
104
|
rollup_stale_days: z.ZodDefault<z.ZodNumber>;
|
|
137
105
|
mission_path: z.ZodOptional<z.ZodString>;
|
|
138
106
|
}, z.core.$strip>, z.ZodTransform<{
|
|
@@ -141,15 +109,12 @@ export declare const StoreConfigSchema: z.ZodObject<{
|
|
|
141
109
|
mission_path?: string | undefined;
|
|
142
110
|
}, {
|
|
143
111
|
archive_destination?: string | undefined;
|
|
144
|
-
archive_path?: string | undefined;
|
|
145
112
|
rollup_stale_days: number;
|
|
146
113
|
mission_path?: string | undefined;
|
|
147
114
|
}>>;
|
|
148
115
|
harness: z.ZodPrefault<z.ZodPipe<z.ZodObject<{
|
|
149
116
|
skills_path: z.ZodOptional<z.ZodString>;
|
|
150
|
-
procedures_path: z.ZodOptional<z.ZodString>;
|
|
151
117
|
guidance_path: z.ZodOptional<z.ZodString>;
|
|
152
|
-
conventions_path: z.ZodOptional<z.ZodString>;
|
|
153
118
|
convention_max_bytes: z.ZodDefault<z.ZodNumber>;
|
|
154
119
|
}, z.core.$strip>, z.ZodTransform<{
|
|
155
120
|
skills_path: string;
|
|
@@ -157,31 +122,17 @@ export declare const StoreConfigSchema: z.ZodObject<{
|
|
|
157
122
|
convention_max_bytes: number;
|
|
158
123
|
}, {
|
|
159
124
|
skills_path?: string | undefined;
|
|
160
|
-
procedures_path?: string | undefined;
|
|
161
125
|
guidance_path?: string | undefined;
|
|
162
|
-
conventions_path?: string | undefined;
|
|
163
126
|
convention_max_bytes: number;
|
|
164
127
|
}>>>;
|
|
165
|
-
adapters: z.ZodDefault<z.
|
|
166
|
-
id: z.ZodString;
|
|
167
|
-
kind: z.ZodString;
|
|
168
|
-
module: z.ZodOptional<z.ZodString>;
|
|
169
|
-
}, z.core.$strip>>, z.ZodTransform<{
|
|
170
|
-
id: string;
|
|
171
|
-
kind: string;
|
|
172
|
-
module?: string | undefined;
|
|
173
|
-
}[], {
|
|
174
|
-
id: string;
|
|
175
|
-
kind: string;
|
|
176
|
-
module?: string | undefined;
|
|
177
|
-
}[]>>, z.ZodArray<z.ZodObject<{
|
|
128
|
+
adapters: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
178
129
|
id: z.ZodString;
|
|
179
130
|
kind: z.ZodEnum<{
|
|
180
131
|
"harness-generation": "harness-generation";
|
|
181
132
|
}>;
|
|
182
133
|
module: z.ZodOptional<z.ZodString>;
|
|
183
134
|
skills_dir: z.ZodOptional<z.ZodString>;
|
|
184
|
-
}, z.core.$strip
|
|
135
|
+
}, z.core.$strip>>>;
|
|
185
136
|
}, z.core.$loose>;
|
|
186
137
|
export type StoreConfig = z.infer<typeof StoreConfigSchema>;
|
|
187
138
|
export type TaxonomyLayerConfig = z.infer<typeof TaxonomyLayerSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAYH;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB;;;;;iBAKvB,CAAC;AAoNH,QAAA,MAAM,wBAAwB;;;;;;;iBAM5B,CAAC;AAiBH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuC1B,CAAC;AAEL,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
package/dist/config/schema.js
CHANGED
|
@@ -5,56 +5,21 @@ import { SHIPPED_DEFAULTS } from './defaults.js';
|
|
|
5
5
|
* store-lifecycle spec: schema_version versions STORE STATE (config shape +
|
|
6
6
|
* note frontmatter conventions) — a monotonic integer independent of the npm
|
|
7
7
|
* package version — not "what this CLI release happens to be."
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Bumped to 2 by the visibility-field key rename migration (store-lifecycle
|
|
11
|
-
* spec task 9.2). Both that field and the config key naming it were removed
|
|
12
|
-
* at schema 7 (see below); the migration survives only to keep the 1 -> 2
|
|
13
|
-
* step in the chain intact.
|
|
14
8
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* (rename-conventions-path-to-guidance-path, 0004-rename-conventions-path-to-guidance-path):
|
|
23
|
-
* `harness.conventions_path` -> `harness.guidance_path`. HarnessSchema's
|
|
24
|
-
* transform accepts the old key through this version too, the same way.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Bumped to 7 on main by the explanation-craft-skill migration
|
|
28
|
-
* (vendor-explanation-craft-skill, 0007-add-explanation-craft-skill), which
|
|
29
|
-
* pins its own local SCHEMA_VERSION and is unaffected by later bumps here.
|
|
9
|
+
* retire-store-migrations: contexture ships no migration mechanism, so this
|
|
10
|
+
* number is a gate rather than a starting point. `readConfig` refuses any
|
|
11
|
+
* store whose recorded version is not exactly this one, in either direction:
|
|
12
|
+
* a newer store because this release cannot know its shape, an older one
|
|
13
|
+
* because this release no longer reads that shape and offers nothing that
|
|
14
|
+
* would bring it forward. A release that changes the store's shape bumps this
|
|
15
|
+
* and documents the one-time fixup in its release notes.
|
|
30
16
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* an older store — `noUnrecognizedConfigKeysCheck` derives from this
|
|
36
|
-
* schema's shape, so an unmigrated store fails `doctor` on the three stale
|
|
37
|
-
* keys until `ctxr migrate` drops them, exactly as `identity` did when
|
|
38
|
-
* remove-agent-identity retired it.
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* Bumped to 9 by the capture-tier change (retain-captures-as-provenance,
|
|
42
|
-
* retain-captures-as-provenance): `ingest.capture_root` is added and
|
|
43
|
-
* `ingest.inbox_path`'s shipped default moves inside it. IngestSchema accepts
|
|
44
|
-
* a config with no `capture_root` so an unmigrated store still loads —
|
|
45
|
-
* `ctxr migrate` has to be able to read the file it is about to rewrite —
|
|
46
|
-
* and skips the nesting rule for exactly that case.
|
|
17
|
+
* It stayed at 10 through that retirement on purpose: nothing about a
|
|
18
|
+
* conforming store's shape changed. What was dropped were superseded INPUT
|
|
19
|
+
* spellings that no store at 10 has ever written, since `renderStoreConfig`
|
|
20
|
+
* only ever emitted the current names.
|
|
47
21
|
*/
|
|
48
22
|
export const SUPPORTED_SCHEMA_VERSION = 10;
|
|
49
|
-
/** The version at which the capture tier became part of the store's shape, and its nesting rule enforceable. */
|
|
50
|
-
export const CAPTURE_TIER_SCHEMA_VERSION = 9;
|
|
51
|
-
/**
|
|
52
|
-
* Bumped to 10 by config-defaults-as-the-convention: every convention key now
|
|
53
|
-
* carries its shipped default here, and a written config omits what it agrees
|
|
54
|
-
* with. Nothing about the shape got stricter — the bump exists so the pruning
|
|
55
|
-
* migration has a `schema_version <` predicate to decide it still has work,
|
|
56
|
-
* the same way every migration in this repo does.
|
|
57
|
-
*/
|
|
58
23
|
export const TaxonomyLayerSchema = z.object({
|
|
59
24
|
name: z.string().min(1),
|
|
60
25
|
path: z.string().min(1),
|
|
@@ -139,6 +104,17 @@ const PublishSchema = z.object({
|
|
|
139
104
|
* `contexture.yaml` predating this key still parses. An empty list opts
|
|
140
105
|
* out entirely — same schema-optional-with-default shape as `publish`.
|
|
141
106
|
*/
|
|
107
|
+
/**
|
|
108
|
+
* cli-contract (keep-the-installed-cli-current): whether session start and
|
|
109
|
+
* update consult the release registry, and how long a resolved answer is
|
|
110
|
+
* reused. Schema-optional with defaults, like `publish` and `skills` — a
|
|
111
|
+
* `contexture.yaml` predating this key parses unchanged, which is why this
|
|
112
|
+
* block needed no schema_version bump.
|
|
113
|
+
*/
|
|
114
|
+
const UpdateCheckSchema = z.object({
|
|
115
|
+
enabled: z.boolean().default(SHIPPED_DEFAULTS.update_check.enabled),
|
|
116
|
+
ttl_hours: z.number().positive().default(SHIPPED_DEFAULTS.update_check.ttl_hours),
|
|
117
|
+
});
|
|
142
118
|
const SkillsSchema = z.object({
|
|
143
119
|
vendored: z.array(z.string()).default([...SHIPPED_DEFAULTS.skills.vendored]),
|
|
144
120
|
});
|
|
@@ -147,10 +123,9 @@ const SkillsSchema = z.object({
|
|
|
147
123
|
* ledger's root and `inbox_path` is the not-yet-ingested state inside it.
|
|
148
124
|
*
|
|
149
125
|
* Both paths carry the shipped convention as a schema default, so a config
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* schema-9 invariant and only that scope can see the version.
|
|
126
|
+
* that declares neither resolves to it. The rule that the inbox sits inside
|
|
127
|
+
* the capture root lives on StoreConfigSchema instead of here, because it
|
|
128
|
+
* spans two keys and only that scope sees both.
|
|
154
129
|
*/
|
|
155
130
|
const IngestSchema = z
|
|
156
131
|
.object({
|
|
@@ -163,22 +138,15 @@ const IngestSchema = z
|
|
|
163
138
|
* context-organize spec: archive's destination — independent of taxonomy
|
|
164
139
|
* layers, so it works under any profile.
|
|
165
140
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* — `ctxr migrate` rewrites the key (and, for a profile that declares a
|
|
172
|
-
* destination, the value) but nothing breaks before it runs.
|
|
173
|
-
*
|
|
174
|
-
* The transform below is the ONLY place the old spelling is read — every
|
|
175
|
-
* other consumer sees `config.organize.archive_destination` and nothing
|
|
176
|
-
* else, so `archive_path` never leaks past config loading.
|
|
141
|
+
* `archive_destination` is the only spelling. Its pre-rename name
|
|
142
|
+
* `archive_path` was accepted here as an input while a migration existed to
|
|
143
|
+
* rewrite it; retire-store-migrations removed both, so a config still
|
|
144
|
+
* carrying the old name now fails the schema-version gate before it reaches
|
|
145
|
+
* this schema at all.
|
|
177
146
|
*/
|
|
178
147
|
const OrganizeSchema = z
|
|
179
148
|
.object({
|
|
180
149
|
archive_destination: z.string().min(1).optional(),
|
|
181
|
-
archive_path: z.string().min(1).optional(),
|
|
182
150
|
/** store-primitives-from-migration-audit spec (D4): the grace period, in days, before a stale rollup is reported — bounds noise from a backlink edited moments ago. */
|
|
183
151
|
rollup_stale_days: z.number().int().nonnegative().default(SHIPPED_DEFAULTS.organize.rollup_stale_days),
|
|
184
152
|
/**
|
|
@@ -200,12 +168,12 @@ const OrganizeSchema = z
|
|
|
200
168
|
* archive-destination-from-taxonomy exists to prevent. Absent under both
|
|
201
169
|
* spellings, the key is reported rather than guessed.
|
|
202
170
|
*/
|
|
203
|
-
const archiveDestination = value.archive_destination
|
|
171
|
+
const archiveDestination = value.archive_destination;
|
|
204
172
|
if (archiveDestination === undefined) {
|
|
205
173
|
ctx.addIssue({
|
|
206
174
|
code: 'custom',
|
|
207
175
|
path: ['archive_destination'],
|
|
208
|
-
message: 'organize.archive_destination is missing. It is resolved from the store taxonomy at init rather than defaulted, so declare it explicitly
|
|
176
|
+
message: 'organize.archive_destination is missing. It is resolved from the store taxonomy at init rather than defaulted, so declare it explicitly.',
|
|
209
177
|
});
|
|
210
178
|
return z.NEVER;
|
|
211
179
|
}
|
|
@@ -230,30 +198,16 @@ const OrganizeSchema = z
|
|
|
230
198
|
* convention files, and the mission document) AGENTS.md's generated
|
|
231
199
|
* sections read from and inline.
|
|
232
200
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* rename-conventions-path-to-guidance-path migration (0004): `guidance_path`
|
|
240
|
-
* is the current key; `conventions_path` is its pre-migration name. Unlike
|
|
241
|
-
* `skills_path`, this key always had a workable default, so an unmigrated
|
|
242
|
-
* store loads silently onto that default rather than erroring — `ctxr
|
|
243
|
-
* migrate` moves the directory and rewrites the key, but nothing breaks if
|
|
244
|
-
* it hasn't run yet.
|
|
245
|
-
*
|
|
246
|
-
* The transform below is the ONLY place any of these spellings is read —
|
|
247
|
-
* every other consumer in the codebase sees `config.harness.skills_path` /
|
|
248
|
-
* `config.harness.guidance_path` and nothing else, so no old key ever leaks
|
|
249
|
-
* past config loading.
|
|
201
|
+
* `skills_path` and `guidance_path` are the only spellings. Their pre-rename
|
|
202
|
+
* names `procedures_path` and `conventions_path` were accepted here as inputs
|
|
203
|
+
* while migrations existed to rewrite them; retire-store-migrations removed
|
|
204
|
+
* both, so a config still carrying either now fails the schema-version gate
|
|
205
|
+
* before it reaches this schema at all.
|
|
250
206
|
*/
|
|
251
207
|
const HarnessSchema = z
|
|
252
208
|
.object({
|
|
253
209
|
skills_path: z.string().min(1).optional(),
|
|
254
|
-
procedures_path: z.string().min(1).optional(),
|
|
255
210
|
guidance_path: z.string().min(1).optional(),
|
|
256
|
-
conventions_path: z.string().min(1).optional(),
|
|
257
211
|
/**
|
|
258
212
|
* compose-store-guidance-documents design.md D6: a size ceiling on
|
|
259
213
|
* AGENTS.md's inlined "Store conventions" section, guarding against
|
|
@@ -267,16 +221,11 @@ const HarnessSchema = z
|
|
|
267
221
|
})
|
|
268
222
|
.transform((value) => {
|
|
269
223
|
/**
|
|
270
|
-
* config-defaults-as-the-convention:
|
|
271
|
-
*
|
|
272
|
-
* changed is the end of the chain — absent under BOTH spellings used to
|
|
273
|
-
* raise a custom "run `ctxr migrate`" error, but an unmigrated store HAS
|
|
274
|
-
* `procedures_path` and never reached it. What it actually rejected was a
|
|
275
|
-
* config declining to name a skills path, which is now a config that
|
|
276
|
-
* accepts the shipped one.
|
|
224
|
+
* config-defaults-as-the-convention: a config declining to name either
|
|
225
|
+
* path is a config accepting the shipped one, not an error.
|
|
277
226
|
*/
|
|
278
|
-
const skillsPath = value.skills_path ??
|
|
279
|
-
const guidancePath = value.guidance_path ??
|
|
227
|
+
const skillsPath = value.skills_path ?? SHIPPED_DEFAULTS.harness.skills_path;
|
|
228
|
+
const guidancePath = value.guidance_path ?? SHIPPED_DEFAULTS.harness.guidance_path;
|
|
280
229
|
// Spread, not a plain key, so the output type keeps `convention_max_bytes`
|
|
281
230
|
// genuinely optional (`key?: number`) rather than always-present-but-possibly-undefined
|
|
282
231
|
// (`key: number | undefined`) — the latter would require every existing
|
|
@@ -302,19 +251,19 @@ const AdapterDeclarationSchema = z.object({
|
|
|
302
251
|
skills_dir: z.string().min(1).optional(),
|
|
303
252
|
});
|
|
304
253
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* `
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
254
|
+
* Every declaration is validated by `AdapterDeclarationSchema` directly, so
|
|
255
|
+
* an unrecognized `kind` fails loudly.
|
|
256
|
+
*
|
|
257
|
+
* retire-store-migrations (D8): this used to pipe through a looser
|
|
258
|
+
* `z.object({ id, kind, module? })` that filtered out the retired
|
|
259
|
+
* `kind: forge` before strict validation, so a store still declaring it
|
|
260
|
+
* could be read by the migration about to rewrite it. That pre-schema was
|
|
261
|
+
* also silently dropping `skills_dir` — zod strips unknown keys, and the
|
|
262
|
+
* looser object never declared it — so a store's declared override never
|
|
263
|
+
* reached `effectiveSkillsDir`. Removing the filter is what makes
|
|
264
|
+
* `adapters[].skills_dir` work at all.
|
|
313
265
|
*/
|
|
314
|
-
const AdaptersFieldSchema = z
|
|
315
|
-
.array(z.object({ id: z.string().min(1), kind: z.string().min(1), module: z.string().min(1).optional() }))
|
|
316
|
-
.transform((declarations) => declarations.filter((d) => d.kind !== 'forge'))
|
|
317
|
-
.pipe(z.array(AdapterDeclarationSchema));
|
|
266
|
+
const AdaptersFieldSchema = z.array(AdapterDeclarationSchema);
|
|
318
267
|
export const StoreConfigSchema = z
|
|
319
268
|
.object({
|
|
320
269
|
schema_version: z.number().int().positive(),
|
|
@@ -330,6 +279,7 @@ export const StoreConfigSchema = z
|
|
|
330
279
|
catalog: CatalogSchema.prefault({}),
|
|
331
280
|
publish: PublishSchema.prefault({}),
|
|
332
281
|
skills: SkillsSchema.prefault({}),
|
|
282
|
+
update_check: UpdateCheckSchema.prefault({}),
|
|
333
283
|
ingest: IngestSchema.prefault({}),
|
|
334
284
|
organize: OrganizeSchema,
|
|
335
285
|
harness: HarnessSchema.prefault({}),
|
|
@@ -340,14 +290,12 @@ export const StoreConfigSchema = z
|
|
|
340
290
|
/**
|
|
341
291
|
* retain-captures-as-provenance (D7): one prefix has to serve both the
|
|
342
292
|
* retrieval exclusion and the write-path gate, which only holds while the
|
|
343
|
-
* inbox is strictly inside the capture root.
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* back
|
|
293
|
+
* inbox is strictly inside the capture root. Unconditional since
|
|
294
|
+
* retire-store-migrations — every config that reaches this refinement is
|
|
295
|
+
* at the supported version, which is exactly what the old version guard
|
|
296
|
+
* tested for. It existed only while migrations had to write configs at
|
|
297
|
+
* earlier versions back to disk.
|
|
348
298
|
*/
|
|
349
|
-
if (value.schema_version < CAPTURE_TIER_SCHEMA_VERSION)
|
|
350
|
-
return;
|
|
351
299
|
if (!isStrictlyUnderPrefix(value.ingest.inbox_path, value.ingest.capture_root)) {
|
|
352
300
|
ctx.addIssue({
|
|
353
301
|
code: 'custom',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,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AAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../../src/core/browse/nav.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../../src/core/browse/nav.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAqGhF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMnD;AAED,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CASzD"}
|
package/dist/core/browse/nav.js
CHANGED
|
@@ -58,7 +58,10 @@ function renderAreaContent(table, area) {
|
|
|
58
58
|
switch (area) {
|
|
59
59
|
case 'publish': {
|
|
60
60
|
const pages = publishPages(table);
|
|
61
|
-
const tree = buildPathTree(pages,
|
|
61
|
+
const tree = buildPathTree(pages,
|
|
62
|
+
// serve-page-names-theme-and-nav-toggle D1: a page's declared name, falling back to its
|
|
63
|
+
// directory segment — the same "one answer to what this is called" principle D6 gives notes.
|
|
64
|
+
(page) => table.publishTitles.get(page) ?? lastSegment(page), (page) => `/publish/${encodeURI(page)}/${PUBLISH_INDEX_FILE}`);
|
|
62
65
|
return renderTree(tree, 0);
|
|
63
66
|
}
|
|
64
67
|
case 'notes': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav.js","sourceRoot":"","sources":["../../../src/core/browse/nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,aAAa,EAAiB,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Y,CAAC,KAAK,CAAC,CAAC,MAAM,uBAAuB,KAAK,CAAC,KAAK,CAAC,IAAI,aAAa,KAAK,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC;IAErK,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,MAAM,OAAO,GAAG,WAAW,YAAY,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QACvF,OAAO,GAAG,OAAO,KAAK,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ThemeMode = 'light' | 'dark' | 'system';
|
|
2
|
+
export interface ResolvedTheme {
|
|
3
|
+
theme: ThemeMode;
|
|
4
|
+
/** A `Set-Cookie` header value to persist the choice, present only when a query parameter just made it. */
|
|
5
|
+
setCookie: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* design.md D6 (serve-page-names-theme-and-nav-toggle): resolves the theme for one response from
|
|
9
|
+
* (in priority order) a `?ctxr-theme=` query parameter on the current request, the persisted
|
|
10
|
+
* cookie, and finally `system` — never a route of its own, so this stays transparent to dispatch.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveTheme(cookieHeader: string | undefined, searchParams: URLSearchParams): ResolvedTheme;
|
|
13
|
+
export type NavState = 'shown' | 'collapsed';
|
|
14
|
+
export interface ResolvedNavState {
|
|
15
|
+
navState: NavState;
|
|
16
|
+
/** A `Set-Cookie` header value to persist the choice, present only when a query parameter just made it. */
|
|
17
|
+
setCookie: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* design.md D9 (serve-page-names-theme-and-nav-toggle): resolves the wide-viewport collapsed/shown
|
|
21
|
+
* state the same way `resolveTheme` resolves a theme — a query parameter, else the persisted
|
|
22
|
+
* cookie, else the default. This governs only the wide-viewport link; the narrow-viewport
|
|
23
|
+
* disclosure is a plain CSS checkbox with no server-side state at all.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveNavState(cookieHeader: string | undefined, searchParams: URLSearchParams): ResolvedNavState;
|
|
26
|
+
//# sourceMappingURL=preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../../src/core/browse/preferences.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AA6DpD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,eAAe,GAAG,aAAa,CAI3G;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAC;AAO7C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,eAAe,GAAG,gBAAgB,CAIjH"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const THEME_MODES = ['light', 'dark', 'system'];
|
|
2
|
+
const THEME_COOKIE = 'ctxr_theme';
|
|
3
|
+
const THEME_QUERY_PARAM = 'ctxr-theme';
|
|
4
|
+
const DEFAULT_THEME = 'system';
|
|
5
|
+
const COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 365;
|
|
6
|
+
/**
|
|
7
|
+
* Minimal Cookie-header parser: "name=value" pairs separated by "; ". The
|
|
8
|
+
* first occurrence of a repeated name wins, the same resolution a browser
|
|
9
|
+
* itself applies when more than one cookie shares a name.
|
|
10
|
+
*/
|
|
11
|
+
function parseCookies(header) {
|
|
12
|
+
const cookies = new Map();
|
|
13
|
+
if (!header)
|
|
14
|
+
return cookies;
|
|
15
|
+
for (const part of header.split(';')) {
|
|
16
|
+
const eq = part.indexOf('=');
|
|
17
|
+
if (eq === -1)
|
|
18
|
+
continue;
|
|
19
|
+
const name = part.slice(0, eq).trim();
|
|
20
|
+
if (name.length === 0 || cookies.has(name))
|
|
21
|
+
continue;
|
|
22
|
+
let value = part.slice(eq + 1).trim();
|
|
23
|
+
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"'))
|
|
24
|
+
value = value.slice(1, -1);
|
|
25
|
+
cookies.set(name, value);
|
|
26
|
+
}
|
|
27
|
+
return cookies;
|
|
28
|
+
}
|
|
29
|
+
function isOneOf(value, allowed) {
|
|
30
|
+
return value !== null && value !== undefined && allowed.includes(value);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* design.md D6/D7 (serve-page-names-theme-and-nav-toggle): a query parameter overrides the
|
|
34
|
+
* persisted cookie for this response and is what gets persisted going forward. An unrecognized
|
|
35
|
+
* cookie value — absent, malformed, from an old or foreign build — is never trusted, and falls
|
|
36
|
+
* back to `fallback` exactly as if no cookie had been sent at all.
|
|
37
|
+
*/
|
|
38
|
+
function resolvePreference(queryValue, cookieValue, allowed, fallback) {
|
|
39
|
+
if (isOneOf(queryValue, allowed))
|
|
40
|
+
return { value: queryValue, fromQueryParam: true };
|
|
41
|
+
if (isOneOf(cookieValue, allowed))
|
|
42
|
+
return { value: cookieValue, fromQueryParam: false };
|
|
43
|
+
return { value: fallback, fromQueryParam: false };
|
|
44
|
+
}
|
|
45
|
+
/** design.md D7: `Path=/`, a one-year lifetime, `SameSite=Lax`, and `HttpOnly` — nothing in this surface ever reads a cookie from script. */
|
|
46
|
+
function setCookieHeader(name, value) {
|
|
47
|
+
return `${name}=${value}; Path=/; Max-Age=${COOKIE_MAX_AGE_SECONDS}; SameSite=Lax; HttpOnly`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* design.md D6 (serve-page-names-theme-and-nav-toggle): resolves the theme for one response from
|
|
51
|
+
* (in priority order) a `?ctxr-theme=` query parameter on the current request, the persisted
|
|
52
|
+
* cookie, and finally `system` — never a route of its own, so this stays transparent to dispatch.
|
|
53
|
+
*/
|
|
54
|
+
export function resolveTheme(cookieHeader, searchParams) {
|
|
55
|
+
const cookies = parseCookies(cookieHeader);
|
|
56
|
+
const resolved = resolvePreference(searchParams.get(THEME_QUERY_PARAM), cookies.get(THEME_COOKIE), THEME_MODES, DEFAULT_THEME);
|
|
57
|
+
return { theme: resolved.value, setCookie: resolved.fromQueryParam ? setCookieHeader(THEME_COOKIE, resolved.value) : undefined };
|
|
58
|
+
}
|
|
59
|
+
const NAV_STATES = ['shown', 'collapsed'];
|
|
60
|
+
const NAV_COOKIE = 'ctxr_nav';
|
|
61
|
+
const NAV_QUERY_PARAM = 'ctxr-nav';
|
|
62
|
+
const DEFAULT_NAV_STATE = 'shown';
|
|
63
|
+
/**
|
|
64
|
+
* design.md D9 (serve-page-names-theme-and-nav-toggle): resolves the wide-viewport collapsed/shown
|
|
65
|
+
* state the same way `resolveTheme` resolves a theme — a query parameter, else the persisted
|
|
66
|
+
* cookie, else the default. This governs only the wide-viewport link; the narrow-viewport
|
|
67
|
+
* disclosure is a plain CSS checkbox with no server-side state at all.
|
|
68
|
+
*/
|
|
69
|
+
export function resolveNavState(cookieHeader, searchParams) {
|
|
70
|
+
const cookies = parseCookies(cookieHeader);
|
|
71
|
+
const resolved = resolvePreference(searchParams.get(NAV_QUERY_PARAM), cookies.get(NAV_COOKIE), NAV_STATES, DEFAULT_NAV_STATE);
|
|
72
|
+
return { navState: resolved.value, setCookie: resolved.fromQueryParam ? setCookieHeader(NAV_COOKIE, resolved.value) : undefined };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=preferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../../src/core/browse/preferences.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACtE,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,aAAa,GAAc,QAAQ,CAAC;AAE1C,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAElD;;;;GAIG;AACH,SAAS,YAAY,CAAC,MAA0B;IAC9C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,KAAK,CAAC,CAAC;YAAE,SAAS;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QACrD,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;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