ctxr-cli 0.33.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.
- package/README.md +15 -1
- package/dist/commands/archive.d.ts +5 -4
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +7 -7
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/catalog-show.d.ts +8 -0
- package/dist/commands/catalog-show.d.ts.map +1 -1
- package/dist/commands/catalog-show.js +29 -2
- package/dist/commands/catalog-show.js.map +1 -1
- package/dist/commands/context-gather.d.ts.map +1 -1
- package/dist/commands/context-gather.js +3 -2
- package/dist/commands/context-gather.js.map +1 -1
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +4 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/graph-build.d.ts +4 -1
- package/dist/commands/graph-build.d.ts.map +1 -1
- package/dist/commands/graph-build.js +14 -5
- package/dist/commands/graph-build.js.map +1 -1
- package/dist/commands/land.d.ts +27 -7
- package/dist/commands/land.d.ts.map +1 -1
- package/dist/commands/land.js +307 -32
- package/dist/commands/land.js.map +1 -1
- package/dist/commands/publish-gather.d.ts.map +1 -1
- package/dist/commands/publish-gather.js +2 -3
- package/dist/commands/publish-gather.js.map +1 -1
- package/dist/commands/review-list.d.ts +19 -5
- package/dist/commands/review-list.d.ts.map +1 -1
- package/dist/commands/review-list.js +55 -6
- package/dist/commands/review-list.js.map +1 -1
- package/dist/commands/rollup-gather.d.ts.map +1 -1
- package/dist/commands/rollup-gather.js +2 -3
- package/dist/commands/rollup-gather.js.map +1 -1
- package/dist/commands/second-opinion.d.ts +33 -0
- package/dist/commands/second-opinion.d.ts.map +1 -0
- package/dist/commands/second-opinion.js +56 -0
- package/dist/commands/second-opinion.js.map +1 -0
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +4 -0
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/session-discard.d.ts +18 -0
- package/dist/commands/session-discard.d.ts.map +1 -0
- package/dist/commands/session-discard.js +31 -0
- package/dist/commands/session-discard.js.map +1 -0
- package/dist/commands/session-list.d.ts +17 -6
- package/dist/commands/session-list.d.ts.map +1 -1
- package/dist/commands/session-list.js +31 -11
- package/dist/commands/session-list.js.map +1 -1
- package/dist/commands/session-rebase.d.ts +18 -0
- package/dist/commands/session-rebase.d.ts.map +1 -0
- package/dist/commands/session-rebase.js +43 -0
- package/dist/commands/session-rebase.js.map +1 -0
- package/dist/commands/session-start.d.ts +8 -0
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +45 -5
- package/dist/commands/session-start.js.map +1 -1
- package/dist/commands/session-status.d.ts +17 -0
- package/dist/commands/session-status.d.ts.map +1 -0
- package/dist/commands/session-status.js +38 -0
- package/dist/commands/session-status.js.map +1 -0
- package/dist/commands/session-submit.d.ts +23 -0
- package/dist/commands/session-submit.d.ts.map +1 -0
- package/dist/commands/session-submit.js +42 -0
- package/dist/commands/session-submit.js.map +1 -0
- package/dist/commands/shared-stores-status.d.ts +24 -0
- package/dist/commands/shared-stores-status.d.ts.map +1 -0
- package/dist/commands/shared-stores-status.js +51 -0
- package/dist/commands/shared-stores-status.js.map +1 -0
- package/dist/commands/shared-stores-sync.d.ts +27 -0
- package/dist/commands/shared-stores-sync.d.ts.map +1 -0
- package/dist/commands/shared-stores-sync.js +115 -0
- package/dist/commands/shared-stores-sync.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +2 -4
- package/dist/commands/verify.js.map +1 -1
- package/dist/config/schema.d.ts +16 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +32 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/core/agents-doc.d.ts +10 -0
- package/dist/core/agents-doc.d.ts.map +1 -1
- package/dist/core/agents-doc.js +26 -1
- package/dist/core/agents-doc.js.map +1 -1
- package/dist/core/approval/decision.d.ts +39 -1
- package/dist/core/approval/decision.d.ts.map +1 -1
- package/dist/core/approval/decision.js +53 -6
- package/dist/core/approval/decision.js.map +1 -1
- package/dist/core/approval/session-group.d.ts +156 -0
- package/dist/core/approval/session-group.d.ts.map +1 -0
- package/dist/core/approval/session-group.js +359 -0
- package/dist/core/approval/session-group.js.map +1 -0
- package/dist/core/approval/session-marker.d.ts +79 -0
- package/dist/core/approval/session-marker.d.ts.map +1 -0
- package/dist/core/approval/session-marker.js +146 -0
- package/dist/core/approval/session-marker.js.map +1 -0
- package/dist/core/approval/store-forges.d.ts +15 -0
- package/dist/core/approval/store-forges.d.ts.map +1 -0
- package/dist/core/approval/store-forges.js +33 -0
- package/dist/core/approval/store-forges.js.map +1 -0
- package/dist/core/browse/approve.d.ts +8 -0
- package/dist/core/browse/approve.d.ts.map +1 -1
- package/dist/core/browse/approve.js +366 -48
- package/dist/core/browse/approve.js.map +1 -1
- package/dist/core/browse/link-resolver.d.ts +9 -4
- package/dist/core/browse/link-resolver.d.ts.map +1 -1
- package/dist/core/browse/link-resolver.js +12 -7
- package/dist/core/browse/link-resolver.js.map +1 -1
- package/dist/core/browse/review.d.ts +5 -0
- package/dist/core/browse/review.d.ts.map +1 -1
- package/dist/core/browse/review.js +8 -0
- package/dist/core/browse/review.js.map +1 -1
- package/dist/core/checks/integrity-checks.d.ts.map +1 -1
- package/dist/core/checks/integrity-checks.js +7 -1
- package/dist/core/checks/integrity-checks.js.map +1 -1
- package/dist/core/checks/manifest.d.ts.map +1 -1
- package/dist/core/checks/manifest.js +2 -0
- package/dist/core/checks/manifest.js.map +1 -1
- package/dist/core/checks/shared-stores-checks.d.ts +17 -0
- package/dist/core/checks/shared-stores-checks.d.ts.map +1 -0
- package/dist/core/checks/shared-stores-checks.js +84 -0
- package/dist/core/checks/shared-stores-checks.js.map +1 -0
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +21 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/forge/github.d.ts +14 -0
- package/dist/core/forge/github.d.ts.map +1 -1
- package/dist/core/forge/github.js +17 -0
- package/dist/core/forge/github.js.map +1 -1
- package/dist/core/git/fast-forward.d.ts +23 -0
- package/dist/core/git/fast-forward.d.ts.map +1 -0
- package/dist/core/git/fast-forward.js +38 -0
- package/dist/core/git/fast-forward.js.map +1 -0
- package/dist/core/git/repo.d.ts +11 -0
- package/dist/core/git/repo.d.ts.map +1 -1
- package/dist/core/git/repo.js +25 -0
- package/dist/core/git/repo.js.map +1 -1
- package/dist/core/graph/model.d.ts +27 -0
- package/dist/core/graph/model.d.ts.map +1 -1
- package/dist/core/graph/model.js +68 -2
- package/dist/core/graph/model.js.map +1 -1
- package/dist/core/graph/persist.d.ts.map +1 -1
- package/dist/core/graph/persist.js +3 -2
- package/dist/core/graph/persist.js.map +1 -1
- package/dist/core/mcp/sessions.d.ts +11 -14
- package/dist/core/mcp/sessions.d.ts.map +1 -1
- package/dist/core/mcp/sessions.js +23 -43
- package/dist/core/mcp/sessions.js.map +1 -1
- package/dist/core/notes/list.d.ts.map +1 -1
- package/dist/core/notes/list.js +5 -0
- package/dist/core/notes/list.js.map +1 -1
- package/dist/core/reconcile.d.ts.map +1 -1
- package/dist/core/reconcile.js +2 -1
- package/dist/core/reconcile.js.map +1 -1
- package/dist/core/retrieval/pass.d.ts.map +1 -1
- package/dist/core/retrieval/pass.js +5 -4
- package/dist/core/retrieval/pass.js.map +1 -1
- package/dist/core/rollup.d.ts.map +1 -1
- package/dist/core/rollup.js +2 -3
- package/dist/core/rollup.js.map +1 -1
- package/dist/core/root.d.ts.map +1 -1
- package/dist/core/root.js +33 -2
- package/dist/core/root.js.map +1 -1
- package/dist/core/second-opinion/environment.d.ts +21 -0
- package/dist/core/second-opinion/environment.d.ts.map +1 -0
- package/dist/core/second-opinion/environment.js +70 -0
- package/dist/core/second-opinion/environment.js.map +1 -0
- package/dist/core/second-opinion/judge.d.ts +29 -0
- package/dist/core/second-opinion/judge.d.ts.map +1 -0
- package/dist/core/second-opinion/judge.js +55 -0
- package/dist/core/second-opinion/judge.js.map +1 -0
- package/dist/core/second-opinion/launch.d.ts +16 -0
- package/dist/core/second-opinion/launch.d.ts.map +1 -0
- package/dist/core/second-opinion/launch.js +75 -0
- package/dist/core/second-opinion/launch.js.map +1 -0
- package/dist/core/second-opinion/lineup.d.ts +82 -0
- package/dist/core/second-opinion/lineup.d.ts.map +1 -0
- package/dist/core/second-opinion/lineup.js +113 -0
- package/dist/core/second-opinion/lineup.js.map +1 -0
- package/dist/core/second-opinion/modes.d.ts +98 -0
- package/dist/core/second-opinion/modes.d.ts.map +1 -0
- package/dist/core/second-opinion/modes.js +224 -0
- package/dist/core/second-opinion/modes.js.map +1 -0
- package/dist/core/second-opinion/prompts.d.ts +18 -0
- package/dist/core/second-opinion/prompts.d.ts.map +1 -0
- package/dist/core/second-opinion/prompts.js +65 -0
- package/dist/core/second-opinion/prompts.js.map +1 -0
- package/dist/core/session/commit.d.ts +29 -0
- package/dist/core/session/commit.d.ts.map +1 -0
- package/dist/core/session/commit.js +22 -0
- package/dist/core/session/commit.js.map +1 -0
- package/dist/core/session/discard.d.ts +24 -0
- package/dist/core/session/discard.d.ts.map +1 -0
- package/dist/core/session/discard.js +68 -0
- package/dist/core/session/discard.js.map +1 -0
- package/dist/core/session/list.d.ts +48 -0
- package/dist/core/session/list.d.ts.map +1 -0
- package/dist/core/session/list.js +55 -0
- package/dist/core/session/list.js.map +1 -0
- package/dist/core/session/rebase.d.ts +34 -0
- package/dist/core/session/rebase.d.ts.map +1 -0
- package/dist/core/session/rebase.js +87 -0
- package/dist/core/session/rebase.js.map +1 -0
- package/dist/core/session/remote.d.ts +80 -0
- package/dist/core/session/remote.d.ts.map +1 -0
- package/dist/core/session/remote.js +102 -0
- package/dist/core/session/remote.js.map +1 -0
- package/dist/core/session/resolve.d.ts +41 -0
- package/dist/core/session/resolve.d.ts.map +1 -0
- package/dist/core/session/resolve.js +109 -0
- package/dist/core/session/resolve.js.map +1 -0
- package/dist/core/session/status.d.ts +47 -0
- package/dist/core/session/status.d.ts.map +1 -0
- package/dist/core/session/status.js +55 -0
- package/dist/core/session/status.js.map +1 -0
- package/dist/core/session/submit.d.ts +67 -0
- package/dist/core/session/submit.d.ts.map +1 -0
- package/dist/core/session/submit.js +254 -0
- package/dist/core/session/submit.js.map +1 -0
- package/dist/core/shared-stores-location.d.ts +17 -0
- package/dist/core/shared-stores-location.d.ts.map +1 -0
- package/dist/core/shared-stores-location.js +22 -0
- package/dist/core/shared-stores-location.js.map +1 -0
- package/dist/core/shared-stores.d.ts +69 -0
- package/dist/core/shared-stores.d.ts.map +1 -0
- package/dist/core/shared-stores.js +100 -0
- package/dist/core/shared-stores.js.map +1 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +14 -10
- package/dist/core/skills.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +122 -6
- package/dist/run.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/templates/agents/shared-stores.md +11 -0
- package/templates/approve/copies-missing.md +1 -0
- package/templates/approve/elsewhere-heading.md +1 -0
- package/templates/approve/elsewhere-intro.md +1 -0
- package/templates/approve/homed-elsewhere.md +1 -0
- package/templates/approve/not-decider.md +1 -0
- package/templates/approve/part-heading.md +1 -0
- package/templates/approve/parts-changed.md +1 -0
- package/templates/approve/session-decision-note.md +1 -0
- package/templates/approve/session-intro.md +1 -0
- package/templates/approve/session-no-decision.md +1 -0
- package/templates/approve/store-unreachable.md +1 -0
- package/templates/land/resolver.md +2 -0
- package/templates/second-opinion/poll-answer.md +7 -0
- package/templates/second-opinion/taste-panel.md +14 -0
- package/templates/session/pages/bare-route.md +2 -0
- package/templates/session/pages/block.md +8 -0
- package/templates/session/pages/condition-preview.md +1 -0
- package/templates/session/pages/condition.md +1 -0
- package/templates/session/pages/moved.md +1 -0
- package/templates/session/pages/stops-working.md +1 -0
- package/templates/session/pages/table-head-preview.md +2 -0
- package/templates/session/pages/table-head.md +2 -0
- package/templates/skills/ctxr-connection-finding.md +4 -1
- package/templates/skills/ctxr-land.md +26 -7
- package/templates/skills/ctxr-placement.md +10 -0
- package/templates/skills/ctxr-rollup.md +3 -0
- package/templates/skills/ctxr-second-opinion.md +52 -36
- package/templates/skills/ctxr-session-lifecycle.md +60 -33
- package/templates/skills/ctxr-submit.md +65 -56
- package/templates/skills/ctxr-second-opinion/run.mjs +0 -542
- /package/templates/{skills/ctxr-second-opinion → second-opinion}/critic-contract.md +0 -0
- /package/templates/{skills/ctxr-second-opinion → second-opinion}/lenses.md +0 -0
- /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/architect.md +0 -0
- /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/pragmatist.md +0 -0
- /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/skeptic.md +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GitResult } from './exec.js';
|
|
2
|
+
export interface FastForwardOutcome {
|
|
3
|
+
/** True when the clone is at the remote's branch afterwards — moved, or already there (`from === to`). */
|
|
4
|
+
synced: boolean;
|
|
5
|
+
from: string | null;
|
|
6
|
+
to: string | null;
|
|
7
|
+
/** Why it was left alone; null when synced. */
|
|
8
|
+
reason: string | null;
|
|
9
|
+
}
|
|
10
|
+
export type CloneGit = (args: readonly string[]) => Promise<GitResult>;
|
|
11
|
+
/**
|
|
12
|
+
* land-sweep-syncs-canonical-clone's rule, shared by `land` and by
|
|
13
|
+
* `ctxr shared-stores sync` (mount-shared-stores D4): fast-forward a clone to
|
|
14
|
+
* `origin/<branch>` only when it is on that branch, has no uncommitted changes
|
|
15
|
+
* to tracked files, and has not diverged. Anything else is somebody's work, so
|
|
16
|
+
* it is reported and left alone — never forced, reset, stashed or switched.
|
|
17
|
+
*
|
|
18
|
+
* `run` runs git in the clone, failures allowed; the caller fetches first,
|
|
19
|
+
* with whatever credential its transport needs. `label` names the clone in a
|
|
20
|
+
* reason ("the canonical clone", "the mount").
|
|
21
|
+
*/
|
|
22
|
+
export declare function fastForwardIfSafe(run: CloneGit, branch: string, label: string): Promise<FastForwardOutcome>;
|
|
23
|
+
//# sourceMappingURL=fast-forward.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-forward.d.ts","sourceRoot":"","sources":["../../../src/core/git/fast-forward.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC,0GAA0G;IAC1G,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoBjH"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* land-sweep-syncs-canonical-clone's rule, shared by `land` and by
|
|
3
|
+
* `ctxr shared-stores sync` (mount-shared-stores D4): fast-forward a clone to
|
|
4
|
+
* `origin/<branch>` only when it is on that branch, has no uncommitted changes
|
|
5
|
+
* to tracked files, and has not diverged. Anything else is somebody's work, so
|
|
6
|
+
* it is reported and left alone — never forced, reset, stashed or switched.
|
|
7
|
+
*
|
|
8
|
+
* `run` runs git in the clone, failures allowed; the caller fetches first,
|
|
9
|
+
* with whatever credential its transport needs. `label` names the clone in a
|
|
10
|
+
* reason ("the canonical clone", "the mount").
|
|
11
|
+
*/
|
|
12
|
+
export async function fastForwardIfSafe(run, branch, label) {
|
|
13
|
+
const head = async (ref) => {
|
|
14
|
+
const r = await run(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]);
|
|
15
|
+
return r.exitCode === 0 ? r.stdout.trim() : null;
|
|
16
|
+
};
|
|
17
|
+
const from = await head('HEAD');
|
|
18
|
+
const leave = (reason) => ({ synced: false, from, to: from, reason });
|
|
19
|
+
const onBranch = (await run(['symbolic-ref', '--quiet', '--short', 'HEAD'])).stdout.trim();
|
|
20
|
+
if (onBranch !== branch)
|
|
21
|
+
return leave(`${label} is on "${onBranch || 'a detached HEAD'}", not ${branch}`);
|
|
22
|
+
const dirty = (await run(['status', '--porcelain', '--untracked-files=no'])).stdout.trim();
|
|
23
|
+
if (dirty !== '')
|
|
24
|
+
return leave(`${label} has uncommitted changes to tracked files`);
|
|
25
|
+
const target = await head(`origin/${branch}`);
|
|
26
|
+
if (target === null)
|
|
27
|
+
return leave(`origin/${branch} could not be read`);
|
|
28
|
+
if (target === from)
|
|
29
|
+
return { synced: true, from, to: from, reason: null };
|
|
30
|
+
const behind = await run(['merge-base', '--is-ancestor', 'HEAD', `origin/${branch}`]);
|
|
31
|
+
if (behind.exitCode !== 0)
|
|
32
|
+
return leave(`${label} has diverged from origin/${branch}`);
|
|
33
|
+
const ff = await run(['merge', '--ff-only', '--quiet', `origin/${branch}`]);
|
|
34
|
+
if (ff.exitCode !== 0)
|
|
35
|
+
return leave(`git refused the fast-forward: ${ff.stderr.trim().split('\n')[0] ?? ''}`);
|
|
36
|
+
return { synced: true, from, to: await head('HEAD'), reason: null };
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=fast-forward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-forward.js","sourceRoot":"","sources":["../../../src/core/git/fast-forward.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAA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C;IACxE,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC3E,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC;IACtF,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,KAAK,6BAA6B,MAAM,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5E,IAAI,EAAE,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,iCAAiC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9G,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACtE,CAAC"}
|
package/dist/core/git/repo.d.ts
CHANGED
|
@@ -71,6 +71,17 @@ export declare function linkedWorktreeGitDir(root: string): string | null;
|
|
|
71
71
|
* answer, never to a wrong tree.
|
|
72
72
|
*/
|
|
73
73
|
export declare function isWorktreeOf(candidate: string, owner: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The main working tree of the repository `root` belongs to, decided from the
|
|
76
|
+
* filesystem alone. A session worktree does not contain the ignored `shared/`
|
|
77
|
+
* directory, so mounts are always read from the main working tree (D7); this is
|
|
78
|
+
* how a command run in a session worktree finds them.
|
|
79
|
+
*
|
|
80
|
+
* A linked worktree's `.git` points at `<main>/.git/worktrees/<name>`, whose
|
|
81
|
+
* `commondir` file names the shared `.git`. Anything that is not a linked
|
|
82
|
+
* worktree is its own main working tree.
|
|
83
|
+
*/
|
|
84
|
+
export declare function mainWorkingTreeRoot(root: string): string;
|
|
74
85
|
/**
|
|
75
86
|
* Whether git has an explicit author identity available, from either source
|
|
76
87
|
* it actually uses at commit time: `GIT_AUTHOR_*`/`GIT_COMMITTER_*`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../../src/core/git/repo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAExB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB,mGAAmG;AACnG,wBAAsB,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAQvF;AAED,qGAAqG;AACrG,wBAAsB,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAc1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,oB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O,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
|
package/dist/core/git/repo.js
CHANGED
|
@@ -105,6 +105,31 @@ export function isWorktreeOf(candidate, owner) {
|
|
|
105
105
|
const rel = path.relative(worktreesDir, gitDir);
|
|
106
106
|
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* The main working tree of the repository `root` belongs to, decided from the
|
|
110
|
+
* filesystem alone. A session worktree does not contain the ignored `shared/`
|
|
111
|
+
* directory, so mounts are always read from the main working tree (D7); this is
|
|
112
|
+
* how a command run in a session worktree finds them.
|
|
113
|
+
*
|
|
114
|
+
* A linked worktree's `.git` points at `<main>/.git/worktrees/<name>`, whose
|
|
115
|
+
* `commondir` file names the shared `.git`. Anything that is not a linked
|
|
116
|
+
* worktree is its own main working tree.
|
|
117
|
+
*/
|
|
118
|
+
export function mainWorkingTreeRoot(root) {
|
|
119
|
+
const gitDir = linkedWorktreeGitDir(root);
|
|
120
|
+
if (gitDir === null)
|
|
121
|
+
return root;
|
|
122
|
+
let commonDir = path.resolve(gitDir, '..', '..');
|
|
123
|
+
try {
|
|
124
|
+
const pointer = readFileSync(path.join(gitDir, 'commondir'), 'utf8').trim();
|
|
125
|
+
if (pointer !== '')
|
|
126
|
+
commonDir = path.resolve(gitDir, pointer);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// No commondir file: fall back to the standard `<main>/.git/worktrees/<name>` layout.
|
|
130
|
+
}
|
|
131
|
+
return path.dirname(commonDir);
|
|
132
|
+
}
|
|
108
133
|
/**
|
|
109
134
|
* Whether git has an explicit author identity available, from either source
|
|
110
135
|
* it actually uses at commit time: `GIT_AUTHOR_*`/`GIT_COMMITTER_*`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../../src/core/git/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EA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OAAe;IAEf,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACrD,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -37,6 +37,8 @@ export interface GraphBuildOptions {
|
|
|
37
37
|
/** Relation names whose section headings type the wikilinks under them (graph-context-document D3). Empty: no typed edges. */
|
|
38
38
|
/** How many leading directory segments form a node's cluster (graph-context-document D2). */
|
|
39
39
|
clusterDepth?: number;
|
|
40
|
+
/** The mount locations of a read view; each note resolves links within its owning store (mount-shared-stores). */
|
|
41
|
+
scopes?: readonly string[];
|
|
40
42
|
}
|
|
41
43
|
export declare const DEFAULT_CLUSTER_DEPTH = 2;
|
|
42
44
|
/** The cluster of a note that lives directly at the store root. */
|
|
@@ -88,6 +90,31 @@ export type StemResolution = {
|
|
|
88
90
|
};
|
|
89
91
|
/** Classifies a wikilink target against a stem index — exactly one match resolves, zero or many don't. */
|
|
90
92
|
export declare function resolveStem(stemIndex: ReadonlyMap<string, string[]>, target: string): StemResolution;
|
|
93
|
+
/**
|
|
94
|
+
* mount-shared-stores (context-retrieval: links resolve within the store that
|
|
95
|
+
* owns the note). `scopes` are the location prefixes of the mounts in a read
|
|
96
|
+
* view, `shared/<name>`; a note under one is owned by that mount, every other
|
|
97
|
+
* note by the store itself. With no scopes everything is one store, and a
|
|
98
|
+
* stem resolves exactly as it always has.
|
|
99
|
+
*/
|
|
100
|
+
export declare function ownerScopeOf(notePath: string, scopes: readonly string[]): string;
|
|
101
|
+
export type LinkResolver = (fromPath: string, target: string) => StemResolution;
|
|
102
|
+
/**
|
|
103
|
+
* The one resolver for a set of notes split into owning stores. A target with
|
|
104
|
+
* no `/` resolves by filename stem among the owning store's notes; a target
|
|
105
|
+
* with one resolves as a path against the owning store's root. A note owned by
|
|
106
|
+
* a mount therefore resolves nothing outside it, and the store's own notes
|
|
107
|
+
* reach a mount only by a path that starts with its location.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createLinkResolver(notes: readonly Note[], scopes?: readonly string[]): LinkResolver;
|
|
110
|
+
/**
|
|
111
|
+
* Whether a link `target` written in `fromPath` names `entityPath` — the
|
|
112
|
+
* backlink test `rollup gather`, `publish gather`, `archive` and the pass's
|
|
113
|
+
* entity selector share. A filename link matches by stem within the owning
|
|
114
|
+
* store, as it always has, even where the stem is ambiguous; a path link
|
|
115
|
+
* matches only when it resolves to the entity.
|
|
116
|
+
*/
|
|
117
|
+
export declare function linkNames(fromPath: string, target: string, entityPath: string, scopes?: readonly string[]): boolean;
|
|
91
118
|
export declare function buildGraphFromNotes(notes: readonly Note[], options?: GraphBuildOptions): GraphBuildResult;
|
|
92
119
|
/** The build options a store's configuration implies — the one place config is translated for the graph. */
|
|
93
120
|
export declare function graphBuildOptions(config: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/core/graph/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,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AC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,cAAc,CAAC;AAEhF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,YAAY,CAoBvG;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAIvH;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CA2B7G;AAED,4GAA4G;AAC5G,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE;QAAE,KAAK,EAAE;YAAE,aAAa,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,GAAG,iBAAiB,CAEhH"}
|
package/dist/core/graph/model.js
CHANGED
|
@@ -106,6 +106,72 @@ export function resolveStem(stemIndex, target) {
|
|
|
106
106
|
return { reason: 'ambiguous' };
|
|
107
107
|
return { path: resolved[0] };
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* mount-shared-stores (context-retrieval: links resolve within the store that
|
|
111
|
+
* owns the note). `scopes` are the location prefixes of the mounts in a read
|
|
112
|
+
* view, `shared/<name>`; a note under one is owned by that mount, every other
|
|
113
|
+
* note by the store itself. With no scopes everything is one store, and a
|
|
114
|
+
* stem resolves exactly as it always has.
|
|
115
|
+
*/
|
|
116
|
+
export function ownerScopeOf(notePath, scopes) {
|
|
117
|
+
for (const scope of scopes)
|
|
118
|
+
if (notePath.startsWith(`${scope}/`))
|
|
119
|
+
return scope;
|
|
120
|
+
return '';
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A path link's target, as a store-relative note path under `owner`, or null
|
|
124
|
+
* when it would leave the owning store's root. `.md` is appended unless the
|
|
125
|
+
* target already carries it.
|
|
126
|
+
*/
|
|
127
|
+
function pathLinkCandidate(owner, target) {
|
|
128
|
+
const normalized = path.posix.normalize(target.replace(/^\/+/, ''));
|
|
129
|
+
if (normalized === '.' || normalized === '..' || normalized.startsWith('../'))
|
|
130
|
+
return null;
|
|
131
|
+
const file = normalized.endsWith('.md') ? normalized : `${normalized}.md`;
|
|
132
|
+
return owner === '' ? file : `${owner}/${file}`;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The one resolver for a set of notes split into owning stores. A target with
|
|
136
|
+
* no `/` resolves by filename stem among the owning store's notes; a target
|
|
137
|
+
* with one resolves as a path against the owning store's root. A note owned by
|
|
138
|
+
* a mount therefore resolves nothing outside it, and the store's own notes
|
|
139
|
+
* reach a mount only by a path that starts with its location.
|
|
140
|
+
*/
|
|
141
|
+
export function createLinkResolver(notes, scopes = []) {
|
|
142
|
+
const byOwner = new Map();
|
|
143
|
+
for (const note of notes) {
|
|
144
|
+
const owner = ownerScopeOf(note.path, scopes);
|
|
145
|
+
const list = byOwner.get(owner) ?? [];
|
|
146
|
+
list.push(note);
|
|
147
|
+
byOwner.set(owner, list);
|
|
148
|
+
}
|
|
149
|
+
const stemIndexes = new Map();
|
|
150
|
+
for (const [owner, owned] of byOwner)
|
|
151
|
+
stemIndexes.set(owner, buildStemIndex(owned));
|
|
152
|
+
const paths = new Set(notes.map((note) => note.path));
|
|
153
|
+
return (fromPath, target) => {
|
|
154
|
+
const owner = ownerScopeOf(fromPath, scopes);
|
|
155
|
+
if (target.includes('/')) {
|
|
156
|
+
const candidate = pathLinkCandidate(owner, target);
|
|
157
|
+
return candidate !== null && paths.has(candidate) ? { path: candidate } : { reason: 'not_found' };
|
|
158
|
+
}
|
|
159
|
+
return resolveStem(stemIndexes.get(owner) ?? new Map(), target);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Whether a link `target` written in `fromPath` names `entityPath` — the
|
|
164
|
+
* backlink test `rollup gather`, `publish gather`, `archive` and the pass's
|
|
165
|
+
* entity selector share. A filename link matches by stem within the owning
|
|
166
|
+
* store, as it always has, even where the stem is ambiguous; a path link
|
|
167
|
+
* matches only when it resolves to the entity.
|
|
168
|
+
*/
|
|
169
|
+
export function linkNames(fromPath, target, entityPath, scopes = []) {
|
|
170
|
+
const owner = ownerScopeOf(fromPath, scopes);
|
|
171
|
+
if (target.includes('/'))
|
|
172
|
+
return pathLinkCandidate(owner, target) === entityPath;
|
|
173
|
+
return ownerScopeOf(entityPath, scopes) === owner && path.basename(entityPath, '.md') === target;
|
|
174
|
+
}
|
|
109
175
|
export function buildGraphFromNotes(notes, options = {}) {
|
|
110
176
|
const idCounts = new Map();
|
|
111
177
|
for (const note of notes)
|
|
@@ -114,14 +180,14 @@ export function buildGraphFromNotes(notes, options = {}) {
|
|
|
114
180
|
if (collisions.length > 0) {
|
|
115
181
|
throw new GraphIdentityCollisionError(collisions);
|
|
116
182
|
}
|
|
117
|
-
const
|
|
183
|
+
const resolve = createLinkResolver(notes, options.scopes ?? []);
|
|
118
184
|
const depth = options.clusterDepth ?? DEFAULT_CLUSTER_DEPTH;
|
|
119
185
|
const nodes = notes.map((n) => ({ id: n.path, path: n.path, cluster: clusterOf(n.path, depth) }));
|
|
120
186
|
const edges = [];
|
|
121
187
|
const dangling = [];
|
|
122
188
|
for (const note of notes) {
|
|
123
189
|
for (const { target, type } of extractLinks(note.body)) {
|
|
124
|
-
const resolution =
|
|
190
|
+
const resolution = resolve(note.path, target);
|
|
125
191
|
if ('reason' in resolution) {
|
|
126
192
|
dangling.push({ from: note.path, target, reason: resolution.reason });
|
|
127
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/core/graph/model.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE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,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAO9E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAQ/E"}
|
|
@@ -2,7 +2,7 @@ import { mkdir, readFile } from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { GraphCarriesExcludedNoteError, GraphNotBuiltError } from '../errors.js';
|
|
4
4
|
import { writeFileAtomic } from '../fs/atomic.js';
|
|
5
|
-
import {
|
|
5
|
+
import { listReadView } from '../shared-stores.js';
|
|
6
6
|
/** A derived artifact, atomically written, under the home directory's cache subpath (the default derived path). */
|
|
7
7
|
export function graphFilePath(store) {
|
|
8
8
|
return path.join(store.root, '.contexture', 'cache', 'graph.json');
|
|
@@ -48,7 +48,8 @@ export async function readAdmittedGraph(store) {
|
|
|
48
48
|
const graph = await readGraph(store);
|
|
49
49
|
if (!graph)
|
|
50
50
|
throw new GraphNotBuiltError();
|
|
51
|
-
|
|
51
|
+
// mount-shared-stores: each node is admitted by the store that owns it, which is what the read view enumerates.
|
|
52
|
+
const admitted = new Set((await listReadView(store.root, store.config)).notes.map((note) => note.path));
|
|
52
53
|
const excluded = graph.nodes.filter((node) => !admitted.has(node.id)).map((node) => node.id);
|
|
53
54
|
if (excluded.length > 0)
|
|
54
55
|
throw new GraphCarriesExcludedNoteError(excluded);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist.js","sourceRoot":"","sources":["../../../src/core/graph/persist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
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Q,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -2,12 +2,18 @@ import type { StoreConfig } from '../../config/schema.js';
|
|
|
2
2
|
import { type ForgeCredentials } from '../forge/credentials.js';
|
|
3
3
|
import type { ForgeClient, PullRequest } from '../forge/github.js';
|
|
4
4
|
import type { GitRunner } from '../git/exec.js';
|
|
5
|
+
import { type PullState } from '../session/remote.js';
|
|
5
6
|
/**
|
|
6
7
|
* serve-the-store-over-mcp design.md D9, D13: the write side the MCP surface
|
|
7
8
|
* shares between `capture` and the member drafts. Everything it writes is an
|
|
8
9
|
* ordinary session — a worktree under the configured worktrees path, on a
|
|
9
10
|
* branch under the session prefix, with a pull request — so the approval page
|
|
10
11
|
* lists it and `ctxr land` lands it with no MCP-specific path anywhere.
|
|
12
|
+
*
|
|
13
|
+
* bring-the-session-lifecycle-into-the-cli (Migration Plan, step 2): push,
|
|
14
|
+
* publish, remove and the commit call itself are `src/core/session/`'s, shared
|
|
15
|
+
* with `ctxr session submit` and `discard`; what stays here is the MCP
|
|
16
|
+
* surface's own wording of their failures.
|
|
11
17
|
*/
|
|
12
18
|
export interface WriteDeps {
|
|
13
19
|
git: GitRunner;
|
|
@@ -32,16 +38,7 @@ export interface Session {
|
|
|
32
38
|
branch: string;
|
|
33
39
|
label: string | null;
|
|
34
40
|
}
|
|
35
|
-
export type PullState
|
|
36
|
-
kind: 'open';
|
|
37
|
-
pull: PullRequest;
|
|
38
|
-
} | {
|
|
39
|
-
kind: 'merged';
|
|
40
|
-
} | {
|
|
41
|
-
kind: 'closed-unmerged';
|
|
42
|
-
} | {
|
|
43
|
-
kind: 'none';
|
|
44
|
-
};
|
|
41
|
+
export type { PullState };
|
|
45
42
|
export declare class WriteRefusal extends Error {
|
|
46
43
|
readonly code: string;
|
|
47
44
|
readonly details?: Record<string, unknown> | undefined;
|
|
@@ -72,10 +69,10 @@ export declare function repoPathOf(deps: WriteDeps, storeRelative: string): Prom
|
|
|
72
69
|
export declare function commitAs(deps: WriteDeps, session: Session, email: string, paths: readonly string[], subject: string, trailer: string): Promise<string>;
|
|
73
70
|
export declare function restore(deps: WriteDeps, session: Session): Promise<void>;
|
|
74
71
|
/**
|
|
75
|
-
* Publishes whatever the session holds that the forge does not
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
72
|
+
* Publishes whatever the session holds that the forge does not, through the
|
|
73
|
+
* shared core's idempotent publish, so a retry after any partial failure
|
|
74
|
+
* converges on exactly one pull request (design.md D9, D13). An open pull
|
|
75
|
+
* request is found, never rewritten: its body is the draft's own.
|
|
79
76
|
*/
|
|
80
77
|
export declare function publish(deps: WriteDeps, session: Session, pull: {
|
|
81
78
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/core/mcp/sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3D
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/core/mcp/sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3D,OAAO,EAA0H,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE9K;;;;;;;;;;;GAWG;AAEH,MAAM,W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|
+
import { addWorktree } from '../git/worktree.js';
|
|
4
4
|
import { generateSessionBranchName, listSessionWorktreeDirs, sessionLabelFromDirName, sessionLabelSlug, worktreePathFor } from '../session.js';
|
|
5
|
+
import { commitStaged } from '../session/commit.js';
|
|
6
|
+
import { firstLines, publishSession, pullStateFor as forgePullState, removeSession as removeSessionWorktree, SessionRemoteError } from '../session/remote.js';
|
|
5
7
|
export class WriteRefusal extends Error {
|
|
6
8
|
code;
|
|
7
9
|
details;
|
|
@@ -21,9 +23,6 @@ export class Mutex {
|
|
|
21
23
|
return next;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
|
-
function firstLines(text, count = 6) {
|
|
25
|
-
return text.trim().split('\n').slice(0, count).join('\n');
|
|
26
|
-
}
|
|
27
26
|
export function approvalUrl(deps, session) {
|
|
28
27
|
return `${deps.baseUrl.replace(/\/+$/, '')}/approve/${encodeURIComponent(session.name)}`;
|
|
29
28
|
}
|
|
@@ -45,20 +44,11 @@ export async function sessionsLabelled(deps, labelPrefix) {
|
|
|
45
44
|
}
|
|
46
45
|
/** What the forge says about the pull requests for `branch`: the open one, else merged, else closed, else none. */
|
|
47
46
|
export async function pullStateFor(deps, branch) {
|
|
48
|
-
|
|
49
|
-
const open = pulls.find((p) => p.state === 'open');
|
|
50
|
-
if (open !== undefined)
|
|
51
|
-
return { kind: 'open', pull: open };
|
|
52
|
-
if (pulls.some((p) => p.merged))
|
|
53
|
-
return { kind: 'merged' };
|
|
54
|
-
if (pulls.length > 0)
|
|
55
|
-
return { kind: 'closed-unmerged' };
|
|
56
|
-
return { kind: 'none' };
|
|
47
|
+
return forgePullState(deps.forge, branch);
|
|
57
48
|
}
|
|
58
49
|
/** A session whose pull request was closed without merging is removed: worktree and local branch (D9, D13). */
|
|
59
50
|
export async function removeSession(deps, session) {
|
|
60
|
-
await
|
|
61
|
-
await deps.git.run(['branch', '-D', session.branch], { cwd: deps.canonicalRoot, allowFailure: true });
|
|
51
|
+
await removeSessionWorktree(deps.git, deps.canonicalRoot, session);
|
|
62
52
|
}
|
|
63
53
|
/** A new session from the freshly fetched default branch, exactly as `ctxr session start` names and places one. */
|
|
64
54
|
export async function startSession(deps, label) {
|
|
@@ -92,14 +82,6 @@ export async function repoPathOf(deps, storeRelative) {
|
|
|
92
82
|
const prefix = deps.repoPrefix ?? (await deps.git.run(['rev-parse', '--show-prefix'], { cwd: deps.canonicalRoot, allowFailure: true })).stdout.trim();
|
|
93
83
|
return `${prefix}${storeRelative}`;
|
|
94
84
|
}
|
|
95
|
-
/** The committer: the host's git identity when it has one, else the recording login's noreply address, as `ctxr land` falls back. */
|
|
96
|
-
async function committerEnv(deps, cwd) {
|
|
97
|
-
const email = (await deps.git.run(['config', '--get', 'user.email'], { cwd, allowFailure: true })).stdout.trim();
|
|
98
|
-
if (email !== '' || deps.env.GIT_COMMITTER_EMAIL || deps.env.EMAIL)
|
|
99
|
-
return {};
|
|
100
|
-
const address = `${deps.recordingLogin.replace(/\[bot\]$/, '')}@users.noreply.github.com`;
|
|
101
|
-
return { GIT_COMMITTER_NAME: deps.recordingLogin, GIT_COMMITTER_EMAIL: address };
|
|
102
|
-
}
|
|
103
85
|
/**
|
|
104
86
|
* Stages `paths` and commits them authored by the member, with the store's
|
|
105
87
|
* hooks running as for any commit. On a refusal the worktree is restored to
|
|
@@ -107,15 +89,19 @@ async function committerEnv(deps, cwd) {
|
|
|
107
89
|
* and the hook's output is the refusal (design.md D13).
|
|
108
90
|
*/
|
|
109
91
|
export async function commitAs(deps, session, email, paths, subject, trailer) {
|
|
110
|
-
const run = (args
|
|
92
|
+
const run = (args) => deps.git.run(args, { cwd: session.path, allowFailure: true });
|
|
111
93
|
const added = await run(['add', '--', ...paths]);
|
|
112
94
|
if (added.exitCode !== 0) {
|
|
113
95
|
await restore(deps, session);
|
|
114
96
|
throw new WriteRefusal('mcp.commit_refused', `The change could not be staged: ${firstLines(added.stderr)}`);
|
|
115
97
|
}
|
|
116
98
|
const name = email.split('@')[0] ?? email;
|
|
117
|
-
const
|
|
118
|
-
|
|
99
|
+
const committed = await commitStaged(deps.git, session.path, deps.env, {
|
|
100
|
+
message: subject,
|
|
101
|
+
author: { name, email },
|
|
102
|
+
trailer: { key: trailer, value: email },
|
|
103
|
+
fallbackCommitter: deps.recordingLogin,
|
|
104
|
+
});
|
|
119
105
|
if (committed.exitCode !== 0) {
|
|
120
106
|
await restore(deps, session);
|
|
121
107
|
throw new WriteRefusal('mcp.commit_refused', `The store refused the change: ${firstLines(`${committed.stdout}\n${committed.stderr}`, 12)}`);
|
|
@@ -127,28 +113,22 @@ export async function restore(deps, session) {
|
|
|
127
113
|
await deps.git.run(['clean', '-fdq'], { cwd: session.path, allowFailure: true });
|
|
128
114
|
}
|
|
129
115
|
/**
|
|
130
|
-
* Publishes whatever the session holds that the forge does not
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
116
|
+
* Publishes whatever the session holds that the forge does not, through the
|
|
117
|
+
* shared core's idempotent publish, so a retry after any partial failure
|
|
118
|
+
* converges on exactly one pull request (design.md D9, D13). An open pull
|
|
119
|
+
* request is found, never rewritten: its body is the draft's own.
|
|
134
120
|
*/
|
|
135
121
|
export async function publish(deps, session, pull) {
|
|
136
|
-
const tip = (await deps.git.run(['rev-parse', 'HEAD'], { cwd: session.path })).stdout.trim();
|
|
137
|
-
const remote = await runRemoteGit(deps.git, deps.credentials, deps.env, ['ls-remote', 'origin', `refs/heads/${session.branch}`], { cwd: session.path, allowFailure: true });
|
|
138
|
-
if (remote.exitCode !== 0 || remote.stdout.split(/\s/)[0] !== tip) {
|
|
139
|
-
const pushed = await runRemoteGit(deps.git, deps.credentials, deps.env, ['push', '--quiet', 'origin', `HEAD:refs/heads/${session.branch}`], { cwd: session.path, allowFailure: true });
|
|
140
|
-
if (pushed.exitCode !== 0) {
|
|
141
|
-
throw new WriteRefusal('mcp.push_failed', `The change is saved in its session but could not be pushed yet (${firstLines(pushed.stderr, 2)}). Retry the same call to publish it.`, { session: session.name });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const state = await pullStateFor(deps, session.branch);
|
|
145
|
-
if (state.kind === 'open')
|
|
146
|
-
return state.pull;
|
|
147
122
|
try {
|
|
148
|
-
return await deps
|
|
123
|
+
return (await publishSession(deps, session, pull)).pull;
|
|
149
124
|
}
|
|
150
125
|
catch (err) {
|
|
151
|
-
|
|
126
|
+
if (!(err instanceof SessionRemoteError))
|
|
127
|
+
throw err;
|
|
128
|
+
if (err.step === 'push') {
|
|
129
|
+
throw new WriteRefusal('mcp.push_failed', `The change is saved in its session but could not be pushed yet (${err.detail}). Retry the same call to publish it.`, { session: session.name });
|
|
130
|
+
}
|
|
131
|
+
throw new WriteRefusal('mcp.pull_request_failed', `The change is pushed but its pull request could not be opened yet (${err.detail}). Retry the same call to open it.`, { session: session.name });
|
|
152
132
|
}
|
|
153
133
|
}
|
|
154
134
|
//# sourceMappingURL=sessions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/core/mcp/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAyB,MAAM,yBAAyB,CAAC;AAG9E,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/core/mcp/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAyB,MAAM,yBAAyB,CAAC;AAG9E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/I,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,IAAI,c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