Skip to content
Myr

stale.ts

This file

Path

apps/cli/src/local/stale.ts

66 lines · 2.0 KiB · TypeScript

Last changed by

Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f

line 1why, one step back
1// A skill copy without the platform's frontmatter is stale: its path is the platform's, so the frontmatter was taken off.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 2–66why, one step back
2import { agentsBlock, upsertAgentsBlock } from "@repo/agent-kit/agents-block";
3import { isStale } from "@repo/agent-kit/generated-file";4import { projectSkill } from "@repo/agent-kit/project-skill";5import type { Policy } from "@repo/protocol/domain/policy";6import type { LandedSha, ProjectName } from "@repo/protocol/ids";7import { Effect, FileSystem, Option, Path } from "effect";89export interface StaleCopy {10 readonly path: string;11 readonly landed: Option.Option<LandedSha>;12}1314const agentsFile = "AGENTS.md";1516export const staleGenerated = (input: {17 readonly root: string;18 readonly project: ProjectName;19 readonly policy: Policy;20 readonly landed: LandedSha;21}): Effect.Effect<22 readonly StaleCopy[],23 never,24 FileSystem.FileSystem | Path.Path25> =>26 Effect.gen(function* () {27 const fs = yield* FileSystem.FileSystem;28 const path = yield* Path.Path;29 const { landed, policy, project } = input;3031 const onDisk = (file: string) =>32 Effect.option(fs.readFileString(path.join(input.root, file)));3334 const skills = yield* projectSkill({ landed, policy, project });3536 const staleSkills = yield* Effect.forEach(skills, (current) =>37 Effect.gen(function* () {38 const copy = yield* onDisk(current.path);3940 if (Option.isNone(copy)) {41 return [];42 }4344 const stale = yield* isStale(copy.value, current);4546 return Option.match(stale, {47 onNone: (): readonly StaleCopy[] => [],48 onSome: (found) => [{ landed: found.landed, path: current.path }],49 });50 })51 );5253 const block = yield* agentsBlock({ landed, policy, project });54 const agents = yield* onDisk(agentsFile);5556 const blockStale = Option.exists(57 agents,58 (text) =>59 text.includes(block.end) && upsertAgentsBlock(text, block) !== text60 );6162 return [63 ...staleSkills.flat(),64 ...(blockStale ? [{ landed: Option.none(), path: agentsFile }] : []),65 ];66 });