Skip to content
Myr

code.ts

This file

Path

packages/project/src/code.ts

110 lines · 3.1 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 1–13why, one step back
1import type { RepoHost } from "@repo/artifacts/repo-host";
2import type {3 CommitDiff,4 CommitView,5 ForkRef,6 PathList,7 RefsView,8 Rev,9 FileView,10 TreeListing,11 WhyView,12} from "@repo/protocol/domain/code";13import type { LandingView } from "@repo/protocol/domain/landing";

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 14why, one step back
14import { keyOf, RepoName } from "@repo/protocol/ids";

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 15–27why, one step back
15import type {
16 CommitSha,17 LandedSha,18 ProjectName,19 RepoPath,20} from "@repo/protocol/ids";21import type {22 UnknownCommit,23 UnknownPath,24 UnknownRevision,25} from "@repo/protocol/refusal";26import { Effect, Option } from "effect";27

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

lines 28–33why, one step back
28import { commitDiff } from "./code/commit.ts";
29import { fileView } from "./code/file.ts";30import { logPage } from "./code/log.ts";31import { pathList } from "./code/paths.ts";32import { refsView } from "./code/refs.ts";33import { listing } from "./code/tree.ts";

Merge branch 'build/912-why-per-line'oscabrielbefore adoption635c3c7

line 34why, one step back
34import { whyView } from "./code/why.ts";

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 35–37why, one step back
35import type { ProjectApi } from "./project.ts";
3637export interface CodeProject {

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

line 38why, one step back
38 readonly project: ProjectName;

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 39why, one step back
39 /** The canonical repo: never a fork's or a layer's. A read reaches a fork only by an address `forks` lists. */

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 40–55why, one step back
40 readonly repo: RepoName;
41 readonly head: Effect.Effect<Option.Option<LandedSha>>;42 /** The landings among `shas`, so a forged trailer never reads as one. */43 readonly landings: (44 shas: readonly CommitSha[]45 ) => Effect.Effect<readonly LandingView[]>;46 readonly forks: Effect.Effect<readonly ForkRef[]>;47}4849export const codeProjectOf = (50 api: ProjectApi,51 project: ProjectName52): CodeProject => ({53 forks: api.forks(),54 head: Effect.map(api.head(), ({ landed }) => Option.fromUndefinedOr(landed)),55 landings: api.landings,

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

line 56why, one step back
56 project,

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 57why, one step back
57 repo: RepoName.make(keyOf(project)),

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 58–60why, one step back
58});
5960export const refsOf = (

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

lines 61–62why, one step back
61 project: CodeProject
62): Effect.Effect<RefsView, never, RepoHost> => refsView(project);

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 63–64why, one step back
63
64export const treeOf = (

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

lines 65–67why, one step back
65 project: CodeProject,
66 at: Option.Option<Rev>,67 path: Option.Option<RepoPath>

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 68why, one step back
68): Effect.Effect<TreeListing, UnknownRevision | UnknownPath, RepoHost> =>

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

line 69why, one step back
69 listing(project, at, path);

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 70–71why, one step back
70
71export const pathsOf = (

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

lines 72–74why, one step back
72 project: CodeProject,
73 at: Option.Option<Rev>74): Effect.Effect<PathList, UnknownRevision, RepoHost> => pathList(project, at);

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 75–76why, one step back
75
76export const fileOf = (

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

lines 77–79why, one step back
77 project: CodeProject,
78 at: Option.Option<Rev>,79 path: RepoPath

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 80why, one step back
80): Effect.Effect<FileView, UnknownRevision | UnknownPath, RepoHost> =>

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

line 81why, one step back
81 fileView(project, at, path);

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 82–83why, one step back
82
83export const logOf = (

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

lines 84–85why, one step back
84 project: CodeProject,
85 input: {

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 86–94why, one step back
86 readonly at: Option.Option<Rev>;
87 readonly path: Option.Option<RepoPath>;88 readonly from: number;89 readonly limit: number;90 }91): Effect.Effect<92 { readonly commits: readonly CommitView[]; readonly next?: number },93 UnknownRevision,94 RepoHost

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

line 95why, one step back
95> => logPage(project, input);

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 96why, one step back
96

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 97why, one step back
97/** `at` names the fork to read the commit in; the canonical repo when absent. */

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 98why, one step back
98export const commitOf = (

Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca

line 99why, one step back
99 project: CodeProject,

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 100–103why, one step back
100 sha: CommitSha,
101 at: Option.Option<Rev> = Option.none()102): Effect.Effect<CommitDiff, UnknownCommit | UnknownRevision, RepoHost> =>103 commitDiff(project, sha, at);

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 104–105why, one step back
104
105export const whyOf = (

Merge branch 'build/912-why-per-line'oscabrielbefore adoption635c3c7

lines 106–108why, one step back
106 project: CodeProject,
107 at: Option.Option<Rev>,108 path: RepoPath

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 109why, one step back
109): Effect.Effect<WhyView, UnknownRevision | UnknownPath, RepoHost> =>

Merge branch 'build/912-why-per-line'oscabrielbefore adoption635c3c7

line 110why, one step back
110 whyView(project, at, path);