Repository navigation
Find a maintained app's Project from its own files - #70
Merged
Merged
Conversation
`firstdraft maintain` read the Project only from planning state, which an app compiled with --output, or any fresh clone of an app, does not have. With publication removed, that is where someone fixing a production error works, so the commands could not run where they are most needed. Every Compilation writes its GapSet into the app as .firstdraft/gaps.json, and its project.id is the Project's ID, which no recompile changes. Without Project state, the maintain commands and a deployed_error report now read that ID. The file holds no origin, so they use the one `login` would select (--staging, FIRSTDRAFT_API_URL, or firstdraft.com) and need a login for it, and maintain says so on standard error. It also records no Compilation, so a deployed_error report from such a copy ends with compilation_not_recorded unless one is named. Planning state, where it exists, still wins. The maintain commands now read the Project once per command and pass it to each request. Checked against a fresh clone of raghubetina/dunbar150-compiled and a local service holding its Project: maintain, maintain show, and maintain resolve each succeeded and printed the note.
Review found that the fallback read gaps.json through a symlinked .firstdraft, which the planning-state reader refuses, so a link into another checkout could act on that checkout's Project; it now requires a real .firstdraft directory. It also decoded malformed UTF-8 leniently; it now refuses it, as the state reader does. The note maintain prints from a fresh clone told every agent where a failure report's Compilation goes, including the agent of a person who said no to reports, who is to hear nothing about them. The note now names only the file and the origin; the report's own compilation_not_recorded detail, reached only with reports on, says the rest. The help texts and the command reference now say which origin a clone uses, that a deployed_error from a clone reads the account first, and that it reads the app's gaps.json for its Project ID.
raghubetina
added a commit
to firstdraft/skills
that referenced
this pull request
Nov 24, 2026
With firstdraft/cli#70, the maintain commands find the Project from the application's own .firstdraft/gaps.json when the planning state is not on this computer, as in a fresh clone or an app compiled with --output. So the Skill now says to run them from the application's folder in every layout. That copy holds no API origin, so the Skill no longer says to read one from planning state that may not exist: it uses the saved api_url when there is one, and otherwise the default origin, or --staging when the owner says so. It also says that a failure report from such a copy needs its Compilation's ID, and to continue without the report when there is none.
raghubetina
marked this pull request as ready for review
November 24, 2026 15:33
raghubetina
added a commit
to firstdraft/skills
that referenced
this pull request
Nov 24, 2026
With firstdraft/cli#70, the maintain commands find the Project from the application's own .firstdraft/gaps.json when the planning state is not on this computer, as in a fresh clone or an app compiled with --output. So the Skill now says to run them from the application's folder in every layout. That copy holds no API origin, so the Skill no longer says to read one from planning state that may not exist: it uses the saved api_url when there is one, and otherwise the default origin, or --staging when the owner says so. It also says that a failure report from such a copy needs its Compilation's ID, and to continue without the report when there is none.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
firstdraft maintainread the Project only from planning state:.firstdraft/state.json, or its archive at.firstdraft/designafter root adoption. An app compiled with--output, and any fresh clone of an app, has neither. With publication removed, that is where someone fixing a production error works, often on another computer, so the commands could not run where they are most needed. firstdraft/firstdraft#1349's issue text says to runfirstdraft maintain show ID"in the app's folder"; this makes that true.What changes
Without Project state, the maintain commands, and
report failure --kind deployed_error, read the Project ID from the app's own.firstdraft/gaps.json. Planning state, where it exists, still wins.What each command needs, and where it comes from now:
state.json.firstdraft/gaps.json,project.idstate.json, pinnedloginwould select:--staging,FIRSTDRAFT_API_URL, orhttps://firstdraft.comfirstdraft startand the agent-started logindeployed_errorreport.firstdraft/compilation.jsoncompilation_not_recordedand sends nothing, unless acompilation.idis given right afterreport failureAfter a successful response from a fresh clone, each maintain command writes one fixed line on standard error,
applicationProjectLineinsrc/agent-sentences.js, after any update line: it names the file and the origin it used, and how to select another origin. It says nothing about reports, so the agent of a person who said no still hears nothing about them. A Project on another origin answersenvironment_not_found, which the existing recovery covers. Agaps.jsonthat is not JSON, whoseformatis notfirstdraft.foundation-gaps/…, or whoseproject.idis not a UUIDv7, islocal_input_unreadable.The maintain commands now read the Project once per command and pass it to each request, instead of reading it per request.
Why
gaps.jsonis a sound sourceRead on the service's
origin/main(fc8e3fb0b):Compilations::PromoteandCompiler::Renderers::FoundationGapsRecordwrite the AnalysisRun's GapSet into every artifact as.firstdraft/gaps.json, byte for byte.Compiler::CompileCapturedProjecttakes the GapSet as a required input, so every service Compilation emits it.Compiler::Gaps::GapSet.buildwritesproject.idfrom the Project's ID: the client-generated UUIDv7 thatplan initcreates and no later push changes. A recompile changesgraph_versionbeside it, not the ID.firstdraft.foundation-gaps/2, and the service caps a GapSet at 32 MiB, which the CLI also uses as its read limit.raghubetina/dunbar150-compiledcommits.firstdraft/gaps.jsonwithproject.id01a20c54-fbc2-7cb1-abce-06e6e516e056; the generated.gitignoreleaves.firstdraftalone.Limits: the app's
AGENTS.mdsays the file is there "if retained", so an owner who deletes.firstdraftloses it, and the command then reportslocal_input_unreadablewith where to run it instead. The file also carries the analyzer and Compiler releases and every gap, none of which the CLI reads.Checks
npm run check: 402 tests pass, with the packed smoke. New tests: a linked.firstdraftand a GapSet that is not UTF-8 (both refused before any request); a fresh clone at the default,--staging, and custom origins for the index, and for a resolution; four malformedgaps.jsonfiles; planning state winning overgaps.json; and adeployed_errorfrom a fresh clone without a Compilation (compilation_not_recorded, nothing sent), with one (sent to the selected origin), and another kind from the same folder (stilllocal_input_unreadable).--depth 1clone ofraghubetina/dunbar150-compiled, against a local service holding a Project with that ID,maintain,maintain show, andmaintain resolve --reason not_a_bug --cause not_a_bugeach succeeded and printed the note.Version
0.10.0 is not published, so this joins its
CHANGELOG.mdentry.Docs: updated docs/commands.md (Maintain a deployed application: where the commands find the Project, the note; the
deployed_errorreport from a clone), docs/errors.md (local_input_unreadable), and CHANGELOG.md (0.10.0). The Skill's guidance follows in firstdraft/skills, and the service's issue text in firstdraft/firstdraft#1349.Review: Codex, approve (2 rounds, 7 findings fixed)