ctxr-cli 0.32.0 → 0.34.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.
Files changed (275) hide show
  1. package/README.md +15 -1
  2. package/dist/commands/archive.d.ts +5 -4
  3. package/dist/commands/archive.d.ts.map +1 -1
  4. package/dist/commands/archive.js +7 -7
  5. package/dist/commands/archive.js.map +1 -1
  6. package/dist/commands/catalog-show.d.ts +8 -0
  7. package/dist/commands/catalog-show.d.ts.map +1 -1
  8. package/dist/commands/catalog-show.js +29 -2
  9. package/dist/commands/catalog-show.js.map +1 -1
  10. package/dist/commands/context-gather.d.ts.map +1 -1
  11. package/dist/commands/context-gather.js +3 -2
  12. package/dist/commands/context-gather.js.map +1 -1
  13. package/dist/commands/doctor.d.ts +5 -1
  14. package/dist/commands/doctor.d.ts.map +1 -1
  15. package/dist/commands/doctor.js +4 -0
  16. package/dist/commands/doctor.js.map +1 -1
  17. package/dist/commands/graph-build.d.ts +4 -1
  18. package/dist/commands/graph-build.d.ts.map +1 -1
  19. package/dist/commands/graph-build.js +14 -5
  20. package/dist/commands/graph-build.js.map +1 -1
  21. package/dist/commands/land.d.ts +27 -7
  22. package/dist/commands/land.d.ts.map +1 -1
  23. package/dist/commands/land.js +307 -32
  24. package/dist/commands/land.js.map +1 -1
  25. package/dist/commands/publish-gather.d.ts.map +1 -1
  26. package/dist/commands/publish-gather.js +2 -3
  27. package/dist/commands/publish-gather.js.map +1 -1
  28. package/dist/commands/review-list.d.ts +19 -5
  29. package/dist/commands/review-list.d.ts.map +1 -1
  30. package/dist/commands/review-list.js +55 -6
  31. package/dist/commands/review-list.js.map +1 -1
  32. package/dist/commands/rollup-gather.d.ts.map +1 -1
  33. package/dist/commands/rollup-gather.js +2 -3
  34. package/dist/commands/rollup-gather.js.map +1 -1
  35. package/dist/commands/second-opinion.d.ts +33 -0
  36. package/dist/commands/second-opinion.d.ts.map +1 -0
  37. package/dist/commands/second-opinion.js +56 -0
  38. package/dist/commands/second-opinion.js.map +1 -0
  39. package/dist/commands/serve.d.ts.map +1 -1
  40. package/dist/commands/serve.js +4 -0
  41. package/dist/commands/serve.js.map +1 -1
  42. package/dist/commands/session-discard.d.ts +18 -0
  43. package/dist/commands/session-discard.d.ts.map +1 -0
  44. package/dist/commands/session-discard.js +31 -0
  45. package/dist/commands/session-discard.js.map +1 -0
  46. package/dist/commands/session-list.d.ts +17 -6
  47. package/dist/commands/session-list.d.ts.map +1 -1
  48. package/dist/commands/session-list.js +31 -11
  49. package/dist/commands/session-list.js.map +1 -1
  50. package/dist/commands/session-rebase.d.ts +18 -0
  51. package/dist/commands/session-rebase.d.ts.map +1 -0
  52. package/dist/commands/session-rebase.js +43 -0
  53. package/dist/commands/session-rebase.js.map +1 -0
  54. package/dist/commands/session-start.d.ts +8 -0
  55. package/dist/commands/session-start.d.ts.map +1 -1
  56. package/dist/commands/session-start.js +45 -5
  57. package/dist/commands/session-start.js.map +1 -1
  58. package/dist/commands/session-status.d.ts +17 -0
  59. package/dist/commands/session-status.d.ts.map +1 -0
  60. package/dist/commands/session-status.js +38 -0
  61. package/dist/commands/session-status.js.map +1 -0
  62. package/dist/commands/session-submit.d.ts +23 -0
  63. package/dist/commands/session-submit.d.ts.map +1 -0
  64. package/dist/commands/session-submit.js +42 -0
  65. package/dist/commands/session-submit.js.map +1 -0
  66. package/dist/commands/shared-stores-status.d.ts +24 -0
  67. package/dist/commands/shared-stores-status.d.ts.map +1 -0
  68. package/dist/commands/shared-stores-status.js +51 -0
  69. package/dist/commands/shared-stores-status.js.map +1 -0
  70. package/dist/commands/shared-stores-sync.d.ts +27 -0
  71. package/dist/commands/shared-stores-sync.d.ts.map +1 -0
  72. package/dist/commands/shared-stores-sync.js +115 -0
  73. package/dist/commands/shared-stores-sync.js.map +1 -0
  74. package/dist/commands/verify.d.ts.map +1 -1
  75. package/dist/commands/verify.js +2 -4
  76. package/dist/commands/verify.js.map +1 -1
  77. package/dist/config/schema.d.ts +16 -0
  78. package/dist/config/schema.d.ts.map +1 -1
  79. package/dist/config/schema.js +32 -0
  80. package/dist/config/schema.js.map +1 -1
  81. package/dist/core/agents-doc.d.ts +10 -0
  82. package/dist/core/agents-doc.d.ts.map +1 -1
  83. package/dist/core/agents-doc.js +26 -1
  84. package/dist/core/agents-doc.js.map +1 -1
  85. package/dist/core/approval/decision.d.ts +39 -1
  86. package/dist/core/approval/decision.d.ts.map +1 -1
  87. package/dist/core/approval/decision.js +53 -6
  88. package/dist/core/approval/decision.js.map +1 -1
  89. package/dist/core/approval/session-group.d.ts +156 -0
  90. package/dist/core/approval/session-group.d.ts.map +1 -0
  91. package/dist/core/approval/session-group.js +359 -0
  92. package/dist/core/approval/session-group.js.map +1 -0
  93. package/dist/core/approval/session-marker.d.ts +79 -0
  94. package/dist/core/approval/session-marker.d.ts.map +1 -0
  95. package/dist/core/approval/session-marker.js +146 -0
  96. package/dist/core/approval/session-marker.js.map +1 -0
  97. package/dist/core/approval/store-forges.d.ts +15 -0
  98. package/dist/core/approval/store-forges.d.ts.map +1 -0
  99. package/dist/core/approval/store-forges.js +33 -0
  100. package/dist/core/approval/store-forges.js.map +1 -0
  101. package/dist/core/browse/approve.d.ts +8 -0
  102. package/dist/core/browse/approve.d.ts.map +1 -1
  103. package/dist/core/browse/approve.js +366 -48
  104. package/dist/core/browse/approve.js.map +1 -1
  105. package/dist/core/browse/link-resolver.d.ts +9 -4
  106. package/dist/core/browse/link-resolver.d.ts.map +1 -1
  107. package/dist/core/browse/link-resolver.js +12 -7
  108. package/dist/core/browse/link-resolver.js.map +1 -1
  109. package/dist/core/browse/review.d.ts +5 -0
  110. package/dist/core/browse/review.d.ts.map +1 -1
  111. package/dist/core/browse/review.js +8 -0
  112. package/dist/core/browse/review.js.map +1 -1
  113. package/dist/core/checks/integrity-checks.d.ts.map +1 -1
  114. package/dist/core/checks/integrity-checks.js +7 -1
  115. package/dist/core/checks/integrity-checks.js.map +1 -1
  116. package/dist/core/checks/manifest.d.ts.map +1 -1
  117. package/dist/core/checks/manifest.js +2 -0
  118. package/dist/core/checks/manifest.js.map +1 -1
  119. package/dist/core/checks/shared-stores-checks.d.ts +17 -0
  120. package/dist/core/checks/shared-stores-checks.d.ts.map +1 -0
  121. package/dist/core/checks/shared-stores-checks.js +84 -0
  122. package/dist/core/checks/shared-stores-checks.js.map +1 -0
  123. package/dist/core/errors.d.ts +17 -0
  124. package/dist/core/errors.d.ts.map +1 -1
  125. package/dist/core/errors.js +21 -0
  126. package/dist/core/errors.js.map +1 -1
  127. package/dist/core/forge/github.d.ts +14 -0
  128. package/dist/core/forge/github.d.ts.map +1 -1
  129. package/dist/core/forge/github.js +17 -0
  130. package/dist/core/forge/github.js.map +1 -1
  131. package/dist/core/git/fast-forward.d.ts +23 -0
  132. package/dist/core/git/fast-forward.d.ts.map +1 -0
  133. package/dist/core/git/fast-forward.js +38 -0
  134. package/dist/core/git/fast-forward.js.map +1 -0
  135. package/dist/core/git/repo.d.ts +11 -0
  136. package/dist/core/git/repo.d.ts.map +1 -1
  137. package/dist/core/git/repo.js +25 -0
  138. package/dist/core/git/repo.js.map +1 -1
  139. package/dist/core/graph/model.d.ts +27 -0
  140. package/dist/core/graph/model.d.ts.map +1 -1
  141. package/dist/core/graph/model.js +68 -2
  142. package/dist/core/graph/model.js.map +1 -1
  143. package/dist/core/graph/persist.d.ts.map +1 -1
  144. package/dist/core/graph/persist.js +3 -2
  145. package/dist/core/graph/persist.js.map +1 -1
  146. package/dist/core/mcp/sessions.d.ts +11 -14
  147. package/dist/core/mcp/sessions.d.ts.map +1 -1
  148. package/dist/core/mcp/sessions.js +23 -43
  149. package/dist/core/mcp/sessions.js.map +1 -1
  150. package/dist/core/notes/list.d.ts.map +1 -1
  151. package/dist/core/notes/list.js +5 -0
  152. package/dist/core/notes/list.js.map +1 -1
  153. package/dist/core/reconcile.d.ts.map +1 -1
  154. package/dist/core/reconcile.js +2 -1
  155. package/dist/core/reconcile.js.map +1 -1
  156. package/dist/core/retrieval/pass.d.ts.map +1 -1
  157. package/dist/core/retrieval/pass.js +5 -4
  158. package/dist/core/retrieval/pass.js.map +1 -1
  159. package/dist/core/rollup.d.ts.map +1 -1
  160. package/dist/core/rollup.js +2 -3
  161. package/dist/core/rollup.js.map +1 -1
  162. package/dist/core/root.d.ts.map +1 -1
  163. package/dist/core/root.js +33 -2
  164. package/dist/core/root.js.map +1 -1
  165. package/dist/core/second-opinion/environment.d.ts +21 -0
  166. package/dist/core/second-opinion/environment.d.ts.map +1 -0
  167. package/dist/core/second-opinion/environment.js +70 -0
  168. package/dist/core/second-opinion/environment.js.map +1 -0
  169. package/dist/core/second-opinion/judge.d.ts +29 -0
  170. package/dist/core/second-opinion/judge.d.ts.map +1 -0
  171. package/dist/core/second-opinion/judge.js +55 -0
  172. package/dist/core/second-opinion/judge.js.map +1 -0
  173. package/dist/core/second-opinion/launch.d.ts +16 -0
  174. package/dist/core/second-opinion/launch.d.ts.map +1 -0
  175. package/dist/core/second-opinion/launch.js +75 -0
  176. package/dist/core/second-opinion/launch.js.map +1 -0
  177. package/dist/core/second-opinion/lineup.d.ts +82 -0
  178. package/dist/core/second-opinion/lineup.d.ts.map +1 -0
  179. package/dist/core/second-opinion/lineup.js +113 -0
  180. package/dist/core/second-opinion/lineup.js.map +1 -0
  181. package/dist/core/second-opinion/modes.d.ts +98 -0
  182. package/dist/core/second-opinion/modes.d.ts.map +1 -0
  183. package/dist/core/second-opinion/modes.js +224 -0
  184. package/dist/core/second-opinion/modes.js.map +1 -0
  185. package/dist/core/second-opinion/prompts.d.ts +18 -0
  186. package/dist/core/second-opinion/prompts.d.ts.map +1 -0
  187. package/dist/core/second-opinion/prompts.js +65 -0
  188. package/dist/core/second-opinion/prompts.js.map +1 -0
  189. package/dist/core/session/commit.d.ts +29 -0
  190. package/dist/core/session/commit.d.ts.map +1 -0
  191. package/dist/core/session/commit.js +22 -0
  192. package/dist/core/session/commit.js.map +1 -0
  193. package/dist/core/session/discard.d.ts +24 -0
  194. package/dist/core/session/discard.d.ts.map +1 -0
  195. package/dist/core/session/discard.js +68 -0
  196. package/dist/core/session/discard.js.map +1 -0
  197. package/dist/core/session/list.d.ts +48 -0
  198. package/dist/core/session/list.d.ts.map +1 -0
  199. package/dist/core/session/list.js +55 -0
  200. package/dist/core/session/list.js.map +1 -0
  201. package/dist/core/session/rebase.d.ts +34 -0
  202. package/dist/core/session/rebase.d.ts.map +1 -0
  203. package/dist/core/session/rebase.js +87 -0
  204. package/dist/core/session/rebase.js.map +1 -0
  205. package/dist/core/session/remote.d.ts +80 -0
  206. package/dist/core/session/remote.d.ts.map +1 -0
  207. package/dist/core/session/remote.js +102 -0
  208. package/dist/core/session/remote.js.map +1 -0
  209. package/dist/core/session/resolve.d.ts +41 -0
  210. package/dist/core/session/resolve.d.ts.map +1 -0
  211. package/dist/core/session/resolve.js +109 -0
  212. package/dist/core/session/resolve.js.map +1 -0
  213. package/dist/core/session/status.d.ts +47 -0
  214. package/dist/core/session/status.d.ts.map +1 -0
  215. package/dist/core/session/status.js +55 -0
  216. package/dist/core/session/status.js.map +1 -0
  217. package/dist/core/session/submit.d.ts +67 -0
  218. package/dist/core/session/submit.d.ts.map +1 -0
  219. package/dist/core/session/submit.js +254 -0
  220. package/dist/core/session/submit.js.map +1 -0
  221. package/dist/core/shared-stores-location.d.ts +17 -0
  222. package/dist/core/shared-stores-location.d.ts.map +1 -0
  223. package/dist/core/shared-stores-location.js +22 -0
  224. package/dist/core/shared-stores-location.js.map +1 -0
  225. package/dist/core/shared-stores.d.ts +69 -0
  226. package/dist/core/shared-stores.d.ts.map +1 -0
  227. package/dist/core/shared-stores.js +100 -0
  228. package/dist/core/shared-stores.js.map +1 -0
  229. package/dist/core/skills.d.ts.map +1 -1
  230. package/dist/core/skills.js +14 -10
  231. package/dist/core/skills.js.map +1 -1
  232. package/dist/run.d.ts.map +1 -1
  233. package/dist/run.js +122 -6
  234. package/dist/run.js.map +1 -1
  235. package/dist/version.d.ts +1 -1
  236. package/dist/version.js +1 -1
  237. package/package.json +1 -1
  238. package/templates/agents/shared-stores.md +11 -0
  239. package/templates/approve/copies-missing.md +1 -0
  240. package/templates/approve/elsewhere-heading.md +1 -0
  241. package/templates/approve/elsewhere-intro.md +1 -0
  242. package/templates/approve/homed-elsewhere.md +1 -0
  243. package/templates/approve/not-decider.md +1 -0
  244. package/templates/approve/part-heading.md +1 -0
  245. package/templates/approve/parts-changed.md +1 -0
  246. package/templates/approve/session-decision-note.md +1 -0
  247. package/templates/approve/session-intro.md +1 -0
  248. package/templates/approve/session-no-decision.md +1 -0
  249. package/templates/approve/store-unreachable.md +1 -0
  250. package/templates/land/resolver.md +2 -0
  251. package/templates/second-opinion/poll-answer.md +7 -0
  252. package/templates/second-opinion/taste-panel.md +14 -0
  253. package/templates/session/pages/bare-route.md +2 -0
  254. package/templates/session/pages/block.md +8 -0
  255. package/templates/session/pages/condition-preview.md +1 -0
  256. package/templates/session/pages/condition.md +1 -0
  257. package/templates/session/pages/moved.md +1 -0
  258. package/templates/session/pages/stops-working.md +1 -0
  259. package/templates/session/pages/table-head-preview.md +2 -0
  260. package/templates/session/pages/table-head.md +2 -0
  261. package/templates/skills/ctxr-capture-circleback/sweep.mjs +33 -6
  262. package/templates/skills/ctxr-capture-circleback.md +9 -6
  263. package/templates/skills/ctxr-connection-finding.md +4 -1
  264. package/templates/skills/ctxr-land.md +26 -7
  265. package/templates/skills/ctxr-placement.md +10 -0
  266. package/templates/skills/ctxr-rollup.md +3 -0
  267. package/templates/skills/ctxr-second-opinion.md +52 -36
  268. package/templates/skills/ctxr-session-lifecycle.md +60 -33
  269. package/templates/skills/ctxr-submit.md +65 -56
  270. package/templates/skills/ctxr-second-opinion/run.mjs +0 -542
  271. /package/templates/{skills/ctxr-second-opinion → second-opinion}/critic-contract.md +0 -0
  272. /package/templates/{skills/ctxr-second-opinion → second-opinion}/lenses.md +0 -0
  273. /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/architect.md +0 -0
  274. /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/pragmatist.md +0 -0
  275. /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/skeptic.md +0 -0
@@ -0,0 +1,254 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { readConfig } from '../../config/load.js';
4
+ import { MIGRATION_STEPS } from '../../config/migrations.js';
5
+ import * as doctorCommand from '../../commands/doctor.js';
6
+ import * as graphDiffCommand from '../../commands/graph-diff.js';
7
+ import { pageUrlsFor } from '../../commands/publish-urls.js';
8
+ import { baseRef } from '../approval/sessions.js';
9
+ import { findSessionMarker, identityOfWorktree, repositorySlug, sessionMarker, sessionRouteName } from '../approval/session-marker.js';
10
+ import { mountingStoreOf } from '../shared-stores.js';
11
+ import { ForgeRequestError } from '../forge/github.js';
12
+ import { ContextureError, SessionRefusedError } from '../errors.js';
13
+ import { ExitCode } from '../exit-codes.js';
14
+ import { hasRemote } from '../git/worktree.js';
15
+ import { packagedTemplate, substituteBlock } from '../templates.js';
16
+ import { commitStaged } from './commit.js';
17
+ import { firstLines, publishSession, remoteTip, SessionRemoteError } from './remote.js';
18
+ import { commitsAhead, rebaseInProgress } from './resolve.js';
19
+ /** A submit that stopped at a step; `details.step` names it and `details.completed` what ran before it. */
20
+ function stopped(exitCode, reason, step, completed, message, details = {}) {
21
+ return new SessionRefusedError(exitCode, reason, message, { step, completed, ...details });
22
+ }
23
+ /** The generated sections' headings, as the templates that write them spell them. */
24
+ function generatedHeadings() {
25
+ return [packagedTemplate('graph/knowledge-changes', 'block'), packagedTemplate('session/pages', 'block')].map((block) => block.split('\n')[0].replace(/^#+\s*/, ''));
26
+ }
27
+ /**
28
+ * D2: the generated sections are the command's, so a body that already
29
+ * carries either heading — as a markdown heading or a bold line — is refused
30
+ * rather than appended to, and the section can be neither duplicated nor
31
+ * hand-edited.
32
+ */
33
+ function headingInBody(body) {
34
+ for (const heading of generatedHeadings()) {
35
+ const escaped = heading.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
36
+ if (new RegExp(`^\\s*(?:#{1,6}\\s+|\\*\\*)${escaped}(?:\\*\\*)?\\s*:?\\s*$`, 'im').test(body))
37
+ return heading;
38
+ }
39
+ return null;
40
+ }
41
+ function under(file, prefix) {
42
+ const normalized = prefix.endsWith('/') ? prefix : `${prefix}/`;
43
+ return file.startsWith(normalized);
44
+ }
45
+ async function openWorktreeStore(session) {
46
+ return { root: session.storeRoot, config: await readConfig(session.storeRoot, MIGRATION_STEPS) };
47
+ }
48
+ function show(address) {
49
+ return `\`${address.url ?? address.route}\``;
50
+ }
51
+ function fill(text, values) {
52
+ return Object.entries(values).reduce((out, [token, value]) => out.replaceAll(`__${token}__`, () => value), text);
53
+ }
54
+ /**
55
+ * The Pages section, built from `ctxr publish urls`' report for the range —
56
+ * every value copied from it, never rebuilt from a path — or null when the
57
+ * report lists no page. The sentences are `templates/session/pages/`'s.
58
+ */
59
+ export function renderPagesSection(pages, base, baseUrlDeclared) {
60
+ if (pages.length === 0)
61
+ return null;
62
+ const template = (name) => packagedTemplate('session/pages', name);
63
+ const previews = pages.some((p) => p.preview !== null);
64
+ const rows = pages.map((page) => {
65
+ let published = page.status === 'removed' ? fill(template('stops-working'), { ADDRESS: show(page.published) }) : show(page.published);
66
+ if (page.moved_from !== null)
67
+ published = fill(template('moved'), { ADDRESS: published, PATH: page.moved_from.path, OLD: show(page.moved_from.published) });
68
+ const cells = [`\`${page.path}\``, page.status, page.lifespan, ...(previews ? [page.preview === null ? '' : show(page.preview)] : []), published];
69
+ return `| ${cells.join(' | ')} |`;
70
+ });
71
+ let text = template('block').replaceAll('__BASE__', () => base);
72
+ text = substituteBlock(text, '__TABLE__', [...template(previews ? 'table-head-preview' : 'table-head').split('\n'), ...rows]);
73
+ text = substituteBlock(text, '__CONDITION__', template(previews ? 'condition-preview' : 'condition').split('\n'));
74
+ text = substituteBlock(text, '__BARE_ROUTE__', baseUrlDeclared ? [] : template('bare-route').split('\n'));
75
+ return text;
76
+ }
77
+ /**
78
+ * D2: the body the pull request carries — the agent's, then the Pages section when there is one, then the Knowledge
79
+ * changes block verbatim, then (approve-sessions-across-stores) the session marker, last, when the session has an
80
+ * identity.
81
+ */
82
+ async function pullBody(session, base, body, identity) {
83
+ const store = await openWorktreeStore(session);
84
+ const knowledge = (await graphDiffCommand.execute(store, { since: base, until: undefined, format: 'markdown' })).humanSummary;
85
+ const pages = renderPagesSection(await pageUrlsFor(store, [`${base}...HEAD`]), base, store.config.serve?.base_url !== undefined);
86
+ return [body.trim(), ...(pages === null ? [] : [pages]), knowledge, ...(identity === null ? [] : [sessionMarker(identity)])].join('\n\n');
87
+ }
88
+ /**
89
+ * The approval page for the session: the home store's, by the home session's name, for a session joined from a
90
+ * mount (approve-sessions-across-stores); otherwise this store's, by the worktree's name.
91
+ */
92
+ async function sessionApprovalAddress(deps, session, identity) {
93
+ if (identity !== null) {
94
+ const mounting = await mountingStoreOf(session.path);
95
+ const ownSlug = await repositorySlug(deps.git, session.path);
96
+ if (mounting !== null && identity.home !== ownSlug)
97
+ return approvalAddress(mounting.config, sessionRouteName(identity));
98
+ }
99
+ return approvalAddress(deps.config, session.name);
100
+ }
101
+ export function approvalAddress(config, name) {
102
+ if (config.change_approval === undefined)
103
+ return null;
104
+ const route = `/approve/${encodeURIComponent(name)}/`;
105
+ const baseUrl = config.serve?.base_url;
106
+ return baseUrl === undefined ? route : `${baseUrl.replace(/\/+$/, '')}${route}`;
107
+ }
108
+ async function checkBranchName(deps, session, wanted) {
109
+ const { git } = deps;
110
+ const refuse = (reason, message) => stopped(ExitCode.Usage, reason, 'arguments', {}, message, { branch: wanted });
111
+ const format = await git.run(['check-ref-format', '--branch', wanted], { cwd: session.path, allowFailure: true });
112
+ if (format.exitCode !== 0 || wanted.startsWith('-'))
113
+ throw refuse('branch_invalid', `"${wanted}" is not a usable branch name.`);
114
+ if (wanted === deps.config.git.default_branch)
115
+ throw refuse('branch_is_default', `"${wanted}" is the default branch; a session is never pushed to it.`);
116
+ if (wanted === session.branch)
117
+ return;
118
+ const local = await git.run(['rev-parse', '--verify', '--quiet', `refs/heads/${wanted}`], { cwd: session.path, allowFailure: true });
119
+ if (local.exitCode === 0)
120
+ throw refuse('branch_taken', `A branch named "${wanted}" already exists in this repository; give this session another name.`);
121
+ if (await hasRemote(git, session.path)) {
122
+ let onRemote = null;
123
+ try {
124
+ onRemote = await remoteTip(deps, session.path, wanted);
125
+ }
126
+ catch (err) {
127
+ if (!(err instanceof SessionRemoteError))
128
+ throw err;
129
+ }
130
+ if (onRemote !== null)
131
+ throw refuse('branch_taken', `The remote already has a branch named "${wanted}"; give this session another name.`);
132
+ }
133
+ // Renaming a branch whose pull request is open would strand that pull request and open a second one.
134
+ let pulls;
135
+ try {
136
+ pulls = await deps.forge.pullsForHead(session.branch);
137
+ }
138
+ catch (err) {
139
+ if (!(err instanceof ForgeRequestError))
140
+ throw err;
141
+ throw stopped(ExitCode.CheckFailed, 'forge_unreachable', 'arguments', {}, `The forge could not be read to check "${session.branch}" for an open pull request before renaming it (${firstLines(err.message, 2)}); nothing was done.`);
142
+ }
143
+ const open = pulls.find((p) => p.state === 'open');
144
+ if (open !== undefined) {
145
+ throw refuse('branch_has_pull_request', `"${session.name}" already has pull request #${open.number} open on branch "${session.branch}"; submit it again with --branch "${session.branch}".`);
146
+ }
147
+ }
148
+ export async function submitSession(deps, session, input) {
149
+ const { git } = deps;
150
+ const cwd = session.path;
151
+ const run = (args) => git.run(args, { cwd, allowFailure: true });
152
+ for (const [name, value] of [['--message', input.message], ['--title', input.title], ['--body', input.body]]) {
153
+ if (value.trim() === '')
154
+ throw stopped(ExitCode.Usage, 'argument_empty', 'arguments', {}, `${name} cannot be empty.`);
155
+ }
156
+ // approve-sessions-across-stores: only the command writes the session marker, so an agent's body cannot claim a session.
157
+ const claimed = findSessionMarker(input.body);
158
+ if (claimed !== null) {
159
+ throw stopped(ExitCode.Usage, 'body_has_session_marker', 'arguments', {}, `The body carries a session marker (${claimed}), which \`ctxr session submit\` writes itself; leave it out of the body.`, { marker: claimed });
160
+ }
161
+ const heading = headingInBody(input.body);
162
+ if (heading !== null) {
163
+ throw stopped(ExitCode.Usage, 'body_has_generated_section', 'arguments', {}, `The body carries a "${heading}" section, which \`ctxr session submit\` writes itself; leave it out of the body.`, { heading });
164
+ }
165
+ if (await rebaseInProgress(git, cwd)) {
166
+ throw stopped(ExitCode.CheckFailed, 'rebase_in_progress', 'arguments', {}, `A rebase is in progress in "${session.name}"; finish it with \`ctxr session rebase ${session.name} --continue\` or undo it with \`ctxr session rebase ${session.name} --abort\`.`);
167
+ }
168
+ await checkBranchName(deps, session, input.branch);
169
+ // Read before any rename: a session started on a generated or joined branch keeps that identity after it is renamed.
170
+ const identity = await identityOfWorktree(git, deps.config, session.path, session.name, session.branch);
171
+ // Revision 2: the whole index, whoever staged it, is checked before anything is staged, so a refusal leaves it as it was.
172
+ const prefix = (await git.run(['rev-parse', '--show-prefix'], { cwd: session.storeRoot })).stdout.trim();
173
+ const derived = deps.config.derived.paths.map((p) => `${prefix}${p}`);
174
+ const indexed = (await run(['diff', '--cached', '--name-status', '--no-renames', '-z'])).stdout.split('\0');
175
+ const derivedStaged = [];
176
+ for (let i = 0; i + 1 < indexed.length; i += 2) {
177
+ if (indexed[i] !== 'D' && derived.some((d) => under(indexed[i + 1], d)))
178
+ derivedStaged.push(indexed[i + 1]);
179
+ }
180
+ if (derivedStaged.length > 0) {
181
+ throw stopped(ExitCode.CheckFailed, 'derived_path_staged', 'staged', {}, `${derivedStaged.map((p) => `"${p}"`).join(', ')} ${derivedStaged.length === 1 ? 'is' : 'are'} staged under a derived path, which is never committed; unstage ${derivedStaged.length === 1 ? 'it' : 'them'} with \`git restore --staged\` and submit again.`, { paths: derivedStaged });
182
+ }
183
+ const added = await run(['add', '-A', '--', ':/', ...derived.map((d) => `:(top,exclude)${d}`)]);
184
+ if (added.exitCode !== 0)
185
+ throw stopped(ExitCode.CheckFailed, 'stage_failed', 'staged', {}, `The session's changes could not be staged: ${added.stderr.trim()}`);
186
+ const staged = (await run(['diff', '--cached', '--name-only', '-z'])).stdout.split('\0').filter((p) => p !== '');
187
+ const completed = { staged };
188
+ const base = await baseRef(git, cwd, deps.config.git.default_branch);
189
+ if (staged.length === 0 && (await commitsAhead(git, cwd, base)) === 0) {
190
+ throw stopped(ExitCode.CheckFailed, 'nothing_to_submit', 'staged', completed, `"${session.name}" has no changes and no commits ahead of ${base}, so there is nothing to submit.`);
191
+ }
192
+ // D1, point 2: the gate is doctor's own store-scope pass, run against the worktree — no second validator.
193
+ // A store doctor cannot even read (a note with unparseable frontmatter) fails the gate as well.
194
+ const doctor = await openWorktreeStore(session)
195
+ .then((store) => doctorCommand.execute({ git }, store))
196
+ .catch((err) => {
197
+ if (err instanceof ContextureError)
198
+ return { exitCode: err.exitCode, findings: [err.finding] };
199
+ throw err;
200
+ });
201
+ if (doctor.exitCode !== ExitCode.Ok) {
202
+ const errors = doctor.findings.filter((f) => f.severity === 'error');
203
+ const listed = errors.slice(0, 5).map((f) => `${f.code}: ${f.message}`).join('; ');
204
+ throw stopped(ExitCode.CheckFailed, 'gate_failed', 'gate', completed, `\`ctxr doctor\` fails in "${session.name}", so nothing was committed: ${listed}${errors.length > 5 ? ` (and ${errors.length - 5} more)` : ''}`, { findings: errors });
205
+ }
206
+ completed.gate = 'pass';
207
+ completed.commit = null;
208
+ if (staged.length > 0) {
209
+ const committed = await commitStaged(git, cwd, deps.env, { ...deps.commit, message: input.message });
210
+ if (committed.exitCode !== 0) {
211
+ throw stopped(ExitCode.CheckFailed, 'commit_refused', 'commit', completed, `The commit was refused: ${`${committed.stdout}\n${committed.stderr}`.trim()}`);
212
+ }
213
+ completed.commit = (await run(['rev-parse', 'HEAD'])).stdout.trim();
214
+ }
215
+ let renamedFrom = null;
216
+ if (input.branch !== session.branch) {
217
+ const renamed = await run(['branch', '-m', input.branch]);
218
+ if (renamed.exitCode !== 0)
219
+ throw stopped(ExitCode.CheckFailed, 'rename_failed', 'branch', completed, `The branch could not be renamed to "${input.branch}": ${renamed.stderr.trim()}`);
220
+ renamedFrom = session.branch;
221
+ }
222
+ completed.branch = renamedFrom === null ? 'kept' : 'renamed';
223
+ const target = { path: cwd, branch: input.branch };
224
+ let published;
225
+ try {
226
+ published = await publishSession(deps, target, { title: input.title, body: await pullBody(session, base, input.body, identity) }, { update: true });
227
+ }
228
+ catch (err) {
229
+ if (!(err instanceof SessionRemoteError))
230
+ throw err;
231
+ throw stopped(ExitCode.CheckFailed, err.step === 'push' ? 'push_failed' : 'pull_request_failed', err.step, completed, `${err.step === 'push' ? `The branch "${input.branch}" could not be pushed` : 'The branch is pushed, but its pull request could not be opened or updated'} (${err.detail}). Everything before this step is in place; run the same submit again to finish.`);
232
+ }
233
+ return {
234
+ session: session.name,
235
+ worktree: cwd,
236
+ branch: input.branch,
237
+ renamed_from: renamedFrom,
238
+ head: (await run(['rev-parse', 'HEAD'])).stdout.trim(),
239
+ steps: { staged, gate: 'pass', commit: completed.commit, branch: completed.branch, push: published.push, pull_request: published.pullRequest },
240
+ pull_request: { number: published.pull.number, url: published.pull.url },
241
+ session_identity: identity,
242
+ approval_url: await sessionApprovalAddress(deps, session, identity),
243
+ };
244
+ }
245
+ /** `--body-file`: the body read from a file, relative to `cwd`. */
246
+ export async function readBodyFile(cwd, file) {
247
+ try {
248
+ return await readFile(path.resolve(cwd, file), 'utf8');
249
+ }
250
+ catch (err) {
251
+ throw stopped(ExitCode.Usage, 'body_file_unreadable', 'arguments', {}, `--body-file "${file}" cannot be read (${err.code ?? 'error'}).`, { file });
252
+ }
253
+ }
254
+ //# sourceMappingURL=submit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../src/core/session/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,E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AC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,IAAY;IAC1D,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,EAAE,EAAE,gBAAgB,IAAI,qBAAsB,GAA6B,CAAC,IAAI,IAAI,OAAO,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAChL,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { StoreConfig } from '../config/schema.js';
2
+ /**
3
+ * mount-shared-stores: the fixed directory every mount sits under (D3, and the
4
+ * critique's first revision). Fixed rather than configurable because path links
5
+ * written into notes carry it, so it has to mean the same thing in every store.
6
+ *
7
+ * Kept apart from `shared-stores.ts` because note enumeration needs it, and
8
+ * `shared-stores.ts` itself enumerates notes.
9
+ */
10
+ export declare const SHARED_STORES_DIR = "shared";
11
+ /** A mount's store-relative location, `shared/<name>`. */
12
+ export declare function mountLocation(name: string): string;
13
+ /** Whether the store declares any mounts. A store with no `shared_stores` key behaves exactly as before. */
14
+ export declare function declaresSharedStores(config: StoreConfig): boolean;
15
+ /** Every declared mount's location: the owning-store scopes link resolution splits a read view by. */
16
+ export declare function mountScopes(config: StoreConfig): string[];
17
+ //# sourceMappingURL=shared-stores-location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-stores-location.d.ts","sourceRoot":"","sources":["../../src/core/shared-stores-location.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,4GAA4G;AAC5G,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAEjE;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAEzD"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * mount-shared-stores: the fixed directory every mount sits under (D3, and the
3
+ * critique's first revision). Fixed rather than configurable because path links
4
+ * written into notes carry it, so it has to mean the same thing in every store.
5
+ *
6
+ * Kept apart from `shared-stores.ts` because note enumeration needs it, and
7
+ * `shared-stores.ts` itself enumerates notes.
8
+ */
9
+ export const SHARED_STORES_DIR = 'shared';
10
+ /** A mount's store-relative location, `shared/<name>`. */
11
+ export function mountLocation(name) {
12
+ return `${SHARED_STORES_DIR}/${name}`;
13
+ }
14
+ /** Whether the store declares any mounts. A store with no `shared_stores` key behaves exactly as before. */
15
+ export function declaresSharedStores(config) {
16
+ return (config.shared_stores ?? []).length > 0;
17
+ }
18
+ /** Every declared mount's location: the owning-store scopes link resolution splits a read view by. */
19
+ export function mountScopes(config) {
20
+ return (config.shared_stores ?? []).map((mount) => mountLocation(mount.name));
21
+ }
22
+ //# sourceMappingURL=shared-stores-location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-stores-location.js","sourceRoot":"","sources":["../../src/core/shared-stores-location.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAE1C,0DAA0D;AAC1D,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,GAAG,iBAAiB,IAAI,IAAI,EAAE,CAAC;AACxC,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,oBAAoB,CAAC,MAAmB;IACtD,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { StoreConfig } from '../config/schema.js';
2
+ import { type GraphBuildResult } from './graph/model.js';
3
+ import { type Note } from './notes/list.js';
4
+ export { mainWorkingTreeRoot } from './git/repo.js';
5
+ export { SHARED_STORES_DIR, declaresSharedStores, mountLocation, mountScopes } from './shared-stores-location.js';
6
+ export type MountState = {
7
+ name: string;
8
+ url: string;
9
+ location: string;
10
+ root: string;
11
+ state: 'present';
12
+ config: StoreConfig;
13
+ } | {
14
+ name: string;
15
+ url: string;
16
+ location: string;
17
+ root: string;
18
+ state: 'absent';
19
+ } | {
20
+ name: string;
21
+ url: string;
22
+ location: string;
23
+ root: string;
24
+ state: 'not_store';
25
+ reason: string;
26
+ };
27
+ /** Every declared mount and whether it can join the read view, read from the main working tree. */
28
+ export declare function resolveMounts(storeRoot: string, config: StoreConfig): Promise<MountState[]>;
29
+ export interface ReadView {
30
+ /** The store's own notes, then each present mount's, every mounted path prefixed by its location. */
31
+ notes: Note[];
32
+ /** The location prefix of every mount that contributed notes; link resolution scopes by these. */
33
+ scopes: string[];
34
+ mounts: MountState[];
35
+ }
36
+ /**
37
+ * context-retrieval (mount-shared-stores): the store's own notes plus each
38
+ * present mount's, each admitted by the configuration of the store that owns
39
+ * it (D5). A store with no mounts gets exactly its own notes and no scopes.
40
+ */
41
+ export declare function listReadView(storeRoot: string, config: StoreConfig): Promise<ReadView>;
42
+ /** The graph of a store's read view: the one build every caller that writes or compares the persisted graph uses. */
43
+ export declare function buildReadViewGraph(storeRoot: string, config: StoreConfig): Promise<{
44
+ graph: GraphBuildResult;
45
+ view: ReadView;
46
+ }>;
47
+ export interface UnavailableMount {
48
+ name: string;
49
+ location: string;
50
+ state: 'absent' | 'not_store';
51
+ reason?: string;
52
+ }
53
+ /** Mounts a read view could not include, as report lines. */
54
+ export declare function unavailableMounts(mounts: readonly MountState[]): UnavailableMount[];
55
+ export interface MountingStore {
56
+ /** The main working tree of the store that declares this one as a mount. */
57
+ root: string;
58
+ config: StoreConfig;
59
+ /** The name it declares this store under. */
60
+ mountName: string;
61
+ }
62
+ /**
63
+ * approve-sessions-across-stores: the store that mounts the store at
64
+ * `storeRoot`, when `storeRoot` is (or is a worktree of) a clone at
65
+ * `shared/<name>` of a store that declares a mount named `<name>`; null
66
+ * otherwise. Decided from the filesystem and that store's configuration alone.
67
+ */
68
+ export declare function mountingStoreOf(storeRoot: string): Promise<MountingStore | null>;
69
+ //# sourceMappingURL=shared-stores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-stores.d.ts","sourceRoot":"","sources":["../../src/core/shared-stores.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAA0C,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAa,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAElH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GACpG;IAAE,IAAI,EAAE,MAA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Aa;IAC5B,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAetF"}
@@ -0,0 +1,100 @@
1
+ import { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { readConfig } from '../config/load.js';
4
+ import { mainWorkingTreeRoot } from './git/repo.js';
5
+ import { buildGraphFromNotes, graphBuildOptions } from './graph/model.js';
6
+ import { listNotes } from './notes/list.js';
7
+ import { CONFIG_FILE_NAME } from './root.js';
8
+ import { declaresSharedStores, mountLocation, mountScopes, SHARED_STORES_DIR as SHARED_STORES_DIR_NAME } from './shared-stores-location.js';
9
+ export { mainWorkingTreeRoot } from './git/repo.js';
10
+ export { SHARED_STORES_DIR, declaresSharedStores, mountLocation, mountScopes } from './shared-stores-location.js';
11
+ /** Every declared mount and whether it can join the read view, read from the main working tree. */
12
+ export async function resolveMounts(storeRoot, config) {
13
+ const mainRoot = mainWorkingTreeRoot(storeRoot);
14
+ const states = [];
15
+ for (const mount of config.shared_stores ?? []) {
16
+ const location = mountLocation(mount.name);
17
+ const root = path.join(mainRoot, ...location.split('/'));
18
+ const base = { name: mount.name, url: mount.url, location, root };
19
+ if (!existsSync(root)) {
20
+ states.push({ ...base, state: 'absent' });
21
+ continue;
22
+ }
23
+ if (!existsSync(path.join(root, CONFIG_FILE_NAME))) {
24
+ states.push({ ...base, state: 'not_store', reason: `no ${CONFIG_FILE_NAME} at the mount's root` });
25
+ continue;
26
+ }
27
+ try {
28
+ states.push({ ...base, state: 'present', config: await readConfig(root) });
29
+ }
30
+ catch (err) {
31
+ states.push({ ...base, state: 'not_store', reason: err instanceof Error ? err.message : String(err) });
32
+ }
33
+ }
34
+ return states;
35
+ }
36
+ /**
37
+ * context-retrieval (mount-shared-stores): the store's own notes plus each
38
+ * present mount's, each admitted by the configuration of the store that owns
39
+ * it (D5). A store with no mounts gets exactly its own notes and no scopes.
40
+ */
41
+ export async function listReadView(storeRoot, config) {
42
+ const own = await listNotes(storeRoot, config);
43
+ if (!declaresSharedStores(config))
44
+ return { notes: own, scopes: [], mounts: [] };
45
+ const mounts = await resolveMounts(storeRoot, config);
46
+ const notes = [...own];
47
+ const scopes = [];
48
+ for (const mount of mounts) {
49
+ if (mount.state !== 'present')
50
+ continue;
51
+ scopes.push(mount.location);
52
+ for (const note of await listNotes(mount.root, mount.config)) {
53
+ notes.push({ ...note, path: `${mount.location}/${note.path}` });
54
+ }
55
+ }
56
+ return { notes, scopes, mounts };
57
+ }
58
+ /** The graph of a store's read view: the one build every caller that writes or compares the persisted graph uses. */
59
+ export async function buildReadViewGraph(storeRoot, config) {
60
+ const view = await listReadView(storeRoot, config);
61
+ return { graph: buildGraphFromNotes(view.notes, { ...graphBuildOptions(config), scopes: mountScopes(config) }), view };
62
+ }
63
+ /** Mounts a read view could not include, as report lines. */
64
+ export function unavailableMounts(mounts) {
65
+ const unavailable = [];
66
+ for (const mount of mounts) {
67
+ if (mount.state === 'absent')
68
+ unavailable.push({ name: mount.name, location: mount.location, state: 'absent' });
69
+ else if (mount.state === 'not_store')
70
+ unavailable.push({ name: mount.name, location: mount.location, state: 'not_store', reason: mount.reason });
71
+ }
72
+ return unavailable;
73
+ }
74
+ /**
75
+ * approve-sessions-across-stores: the store that mounts the store at
76
+ * `storeRoot`, when `storeRoot` is (or is a worktree of) a clone at
77
+ * `shared/<name>` of a store that declares a mount named `<name>`; null
78
+ * otherwise. Decided from the filesystem and that store's configuration alone.
79
+ */
80
+ export async function mountingStoreOf(storeRoot) {
81
+ const clone = mainWorkingTreeRoot(storeRoot);
82
+ const sharedDir = path.dirname(clone);
83
+ if (path.basename(sharedDir) !== SHARED_STORES_DIR_NAME)
84
+ return null;
85
+ const root = path.dirname(sharedDir);
86
+ if (!existsSync(path.join(root, CONFIG_FILE_NAME)))
87
+ return null;
88
+ let config;
89
+ try {
90
+ config = await readConfig(root);
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ const mountName = path.basename(clone);
96
+ if (!(config.shared_stores ?? []).some((mount) => mount.name === mountName))
97
+ return null;
98
+ return { root, config, mountName };
99
+ }
100
+ //# sourceMappingURL=shared-stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-stores.js","sourceRoot":"","sources":["../../src/core/shared-stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAyB,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,SAAS,EAAa,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE5I,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAOlH,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,SAAiB,EAAE,MAAmB;IACxE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC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;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,GAAE,SAAS,SAAS,EAA6B,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiBjJ;AAwBD;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,6FAA6F;AAC7F,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AAyDnE;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,CA6EpJ"}
@@ -18,7 +18,9 @@ function skillTemplate(slug) {
18
18
  }
19
19
  /**
20
20
  * ship-a-cross-model-second-opinion-skill D1: an owned skill may carry
21
- * packaged files beside its SKILL.md — a runner script, prompt fragments —
21
+ * packaged files beside its SKILL.md — a runner script, prompt fragments
22
+ * (today only `ctxr-capture-circleback`; run-the-second-opinion-from-the-cli
23
+ * moved the second opinion's into the CLI) —
22
24
  * authored under `templates/skills/<slug>/`, next to the body template
23
25
  * `templates/skills/<slug>.md`. Read verbatim (they are code and prompt
24
26
  * text, not store-rendered prose, so no `__TOKEN__` substitution) and in
@@ -193,7 +195,7 @@ const MISSION = {
193
195
  const SUBMIT = {
194
196
  file: 'ctxr-submit',
195
197
  name: 'Submit',
196
- description: 'End a working session — re-scan, capture once, stage surgically, validate, gate the external side effect, and open the reviewed pull request with git and gh.',
198
+ description: 'End a working session — re-scan, capture once, hold one unit, validate, and open the reviewed pull request with ctxr session submit, which gates, commits, pushes and writes the generated sections.',
197
199
  body: (config) => skillTemplate('ctxr-submit').replaceAll('__DEFAULT_BRANCH__', config.git.default_branch).split('\n'),
198
200
  };
199
201
  const LAND = {
@@ -205,7 +207,7 @@ const LAND = {
205
207
  const SESSION_LIFECYCLE = {
206
208
  file: 'ctxr-session-lifecycle',
207
209
  name: 'Session lifecycle',
208
- description: 'Start a session worktree, re-scan before any plan, resolve conflicts, sequence multiple pull requests, and reclaim worktrees with git — the frame ctxr-submit and ctxr-land sit inside.',
210
+ description: 'Start a session worktree, re-scan before any plan, resolve conflicts, sequence multiple pull requests, and reclaim worktrees with the ctxr session commands — the frame ctxr-submit and ctxr-land sit inside.',
209
211
  body: (config) => skillTemplate('ctxr-session-lifecycle').replaceAll('__DEFAULT_BRANCH__', config.git.default_branch).split('\n'),
210
212
  };
211
213
  /** Where this store's operator-authored conventions live, for a skill to name by path. */
@@ -252,18 +254,20 @@ const PUBLISH = {
252
254
  body: () => skillTemplate('ctxr-publish').split('\n'),
253
255
  };
254
256
  /**
255
- * ship-a-cross-model-second-opinion-skill: the first owned skill that ships
256
- * more than its SKILL.md. The runner and its prompt fragments live under
257
- * `templates/skills/ctxr-second-opinion/`, and the body names where the
258
- * store's skills path put them. Named for the judgment, not a command: there
259
- * is no `ctxr second-opinion`, and the skill drives no ctxr command at all.
257
+ * ship-a-cross-model-second-opinion-skill, revised by
258
+ * run-the-second-opinion-from-the-cli D1 and D4: the skill is one file again.
259
+ * Its runner became `ctxr second-opinion` and its prompts package templates
260
+ * under `templates/second-opinion/`, so it carries no supporting files, and
261
+ * `ctxr update` prunes the `run.mjs`, `critic-contract.md`, `lenses.md` and
262
+ * `personas/` an earlier release left in a store. Named for the command
263
+ * group it drives, `ctxr second-opinion`; the judgment (when to critique,
264
+ * how to synthesize, what never to execute) stays in the skill.
260
265
  */
261
266
  const SECOND_OPINION = {
262
267
  file: 'ctxr-second-opinion',
263
268
  name: 'Second opinion',
264
269
  description: 'Get an independent critique of a plan, or a poll on a taste call, from three different model families run in parallel, and synthesize their answers without running the plan.',
265
- body: (config) => skillTemplate('ctxr-second-opinion').replaceAll('__SKILLS_PATH__', config.harness.skills_path.replace(/\/+$/, '')).split('\n'),
266
- supportingFiles: () => skillSupportingFiles('ctxr-second-opinion'),
270
+ body: () => skillTemplate('ctxr-second-opinion').split('\n'),
267
271
  };
268
272
  /**
269
273
  * research-and-capture-identity: the research method, written against whatever