22 * InstructionManager - changes instruction files and who reads them.
33 *
44 * Every write starts from the id the client sent, which `InstructionCatalog.resolve` looks up in
5- * the table again, so a client can only reach files the table names. Writes run one request at a
6- * time, and a project file is only written when its folder is a registered project .
5+ * the table again, so a client can only reach files the table names, and only the files of a
6+ * registered project's folder, which the catalog checks. Writes run one request at a time .
77 *
88 * - A file's text is replaced at its real path behind any links, by temp file and rename, and only
99 * if its revision is still the one the client read.
@@ -42,7 +42,6 @@ import type * as PlatformError from "effect/PlatformError";
4242import * as Semaphore from "effect/Semaphore" ;
4343import { writeFileStringAtomically } from "@t3tools/shared/atomicWrite" ;
4444
45- import * as ProjectService from "../project/ProjectService.ts" ;
4645import { editJsoncFile , readSettingsText } from "../skills/JsoncSettings.ts" ;
4746import { excludeNewFile } from "../skills/SkillGitExclude.ts" ;
4847import { removeLink } from "../skills/SkillLinks.ts" ;
@@ -129,7 +128,6 @@ const make = Effect.gen(function* () {
129128 const fileSystem = yield * FileSystem . FileSystem ;
130129 const path = yield * Path . Path ;
131130 const catalog = yield * InstructionCatalog . InstructionCatalog ;
132- const projects = yield * ProjectService . ProjectService ;
133131 const writeLock = yield * Semaphore . make ( 1 ) ;
134132 const fileSystemContext = yield * Effect . context <
135133 FileSystem . FileSystem | Path . Path | VcsProcess . VcsProcess
@@ -185,25 +183,6 @@ const make = Effect.gen(function* () {
185183 cannotWrite ( file ) ,
186184 ) ;
187185
188- /** Project files are only written under a folder the environment knows as a project. */
189- const requireProject = ( cwd : string | undefined ) =>
190- cwd === undefined
191- ? Effect . fail ( refuse ( "unknownEntry" , "That isn't an instruction file T3 Code manages." ) )
192- : projects . getByWorkspaceRoot ( cwd ) . pipe (
193- Effect . orDie ,
194- Effect . filterOrFail ( Option . isSome , ( ) =>
195- refuse ( "unregisteredProject" , "That folder isn't a project in this environment." ) ,
196- ) ,
197- ) ;
198-
199- const resolveEntry = Effect . fnUntraced ( function * ( input : {
200- readonly cwd ?: string | undefined ;
201- readonly id : string ;
202- } ) {
203- if ( input . id . startsWith ( "project:" ) ) yield * requireProject ( input . cwd ) ;
204- return yield * catalog . resolve ( input ) ;
205- } ) ;
206-
207186 const importTargetOf = (
208187 claudeMd : string ,
209188 view : InstructionCatalog . SharedView ,
@@ -220,7 +199,7 @@ const make = Effect.gen(function* () {
220199 function * ( input ) {
221200 return yield * writeLock . withPermits ( 1 ) (
222201 Effect . gen ( function * ( ) {
223- const entry = yield * resolveEntry ( input ) ;
202+ const entry = yield * catalog . resolve ( input ) ;
224203 if ( entry . readOnly ) {
225204 return yield * refuse ( "readOnly" , "That file is set by your organization." ) ;
226205 }
@@ -425,7 +404,7 @@ const make = Effect.gen(function* () {
425404 ) =>
426405 writeLock . withPermits ( 1 ) (
427406 Effect . gen ( function * ( ) {
428- const entry = yield * resolveEntry ( input ) ;
407+ const entry = yield * catalog . resolve ( input ) ;
429408 if ( entry . scope !== "global" || entry . kind !== "shared" ) {
430409 return yield * refuse (
431410 "unknownEntry" ,
@@ -481,7 +460,7 @@ const make = Effect.gen(function* () {
481460 function * ( input ) {
482461 yield * writeLock . withPermits ( 1 ) (
483462 Effect . gen ( function * ( ) {
484- const entry = yield * resolveEntry ( input ) ;
463+ const entry = yield * catalog . resolve ( input ) ;
485464 if ( entry . kind !== "claude" || entry . relativePath !== "CLAUDE.md" ) {
486465 return yield * refuse ( "unknownEntry" , "Only a project's CLAUDE.md can be shared." ) ;
487466 }
@@ -543,7 +522,7 @@ const make = Effect.gen(function* () {
543522 function * ( input ) {
544523 yield * writeLock . withPermits ( 1 ) (
545524 Effect . gen ( function * ( ) {
546- const entry = yield * resolveEntry ( input ) ;
525+ const entry = yield * catalog . resolve ( input ) ;
547526 if ( entry . kind !== "agentOwn" || entry . owner === undefined ) {
548527 return yield * refuse ( "unknownEntry" , "Only an agent's own instructions can be moved." ) ;
549528 }
@@ -610,7 +589,7 @@ const make = Effect.gen(function* () {
610589 function * ( input ) {
611590 yield * writeLock . withPermits ( 1 ) (
612591 Effect . gen ( function * ( ) {
613- const entry = yield * resolveEntry ( input ) ;
592+ const entry = yield * catalog . resolve ( input ) ;
614593 if ( entry . readOnly ) {
615594 return yield * refuse ( "readOnly" , "That file is set by your organization." ) ;
616595 }
0 commit comments