Repository navigation
feat(ui): craftar ui --allow-writes — Sync and Discard edit, confirmed in the page (0.37.0) - #76
Merged
Merged
Conversation
Spec 40 §12.5: the page constants, the 405 of a non-GET and the reading routes' answers, captured before Part C.
…raftar ui Spec 40 Part C: the ui write routes answer with the shape of mcp's sync tool; syncToolResult is that shape's one builder.
…the page's Spec 40 §6.5: the page shows an orphan-drift file's body before a discard; drift show's read and its example-file test move to orphanDriftBody.
Spec 40 §6.4: a path Forge, a fresh digest and, for discard, one hand-edited row; then syncWorkspace, answered with mcp's sync result.
…ontent-Type and a 4096-byte body Spec 40 §6.3: the checks in order; without the flag every answer is the read-only server's.
…oses Spec 40 §6.3 step 8: the request is destroyed once the answer has finished, not before.
… list, comments to the file's style No behaviour change.
…y route call No behaviour change.
No behaviour change.
…irmed in the page Spec 40 §6.5: Discard edit only inside an open diff, never for the example file; without the flag the script is the read-only page's, byte for byte.
…vives the reload Spec 40 §6.5: the page's writing script, driven in a stubbed DOM by the test.
Spec 40 §6.1: typing the flag is the consent; the terminal says writes are allowed, and without it the command is the read-only one.
…openWorldHint on the writing tools Two checks left open by 0.35.0's review.
Spec 41's orphanReason now gives the removed reason for non-discarded files.
The words craftar drift discard prints for the path it discards; every other removal keeps spec 41's orphanReason.
Spec 40 §6: the Commands row, the status line, Phase 1's shipped list and Upgrading › to 0.37.0.
One spelling of the path under src/ (node-cli rule).
…ion names it Spec 40 §6.4 step 2: the registry's record can be stale; refuseRemote throws before the Forge is read.
A disk error while hashing is the workspace's state (409), not ours (500).
A remote Forge or an unset declared parameter: the same gates as Sync.
The `to` header in the diff response now uses the same wording as `craftar diff` for orphans due to agents-md.primary: "written to AGENTS.md only" instead of "no longer produced".
primaryOrphan answers only for orphan; the orphan-drift header keeps its words.
This reverts commit 0b35dcd.
…ary orphan Spec 41 §4.8.
drift discard and the page's discard print the same words.
orphanDriftBody reads the body since spec 40 Part C.
The backslashes JSON doubles were not regex-escaped; the pins failed on windows-latest only.
…he client Spec 40 §6.3 step 8: destroying a request with unread body reset the connection on Windows before the answer was read; nothing past 4096 bytes is kept, and draining stops at 1 MiB.
Asserts the order, so the reset c886529 fixed is caught on Linux, not only on windows-latest.
Including the one that crosses 4096 bytes.
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.
Summary
craftar@0.37.0to npm after approval in thenpmenvironment.craftar ui --allow-writes. Typing the flag is the consent. The page then offers Sync for a workspace and Discard edit for one hand-edited file (drift/orphan-drift, offered only from its open diff), each confirmed in the page. Sync never passes--overwrite-drift, and a discard is adrift discardof that one path. Neither is offered for.claude/settings.craftar.example.json, nor for a workspace whose Forge is remote. A write is refused when the workspace changed since the page showed it (a status digest).POST /api/workspaces/<id>/sync{digest}and…/discard{digest, path}.Host→OriginandSec-Fetch-Site(both required for a POST) → route (405 withAllow) → token →Content-Type(415) → body ≤ 4096 bytes counted as it arrives (413), parsed strictly (400) → a queue of one.not a hand-edited file, the path never echoed) → unset parameter (409) →syncWorkspace. The answer has the shape of the MCPsynctool's result.craftar uiis unchanged, with one exception. The page, its script and stylesheet (pinned by sha256), the 405s and the three terminal lines are byte for byte 0.36.0's, and so is every answer exceptGET /api/workspaces, which gainswrites: false.syncToolResult(src/core/write-actions.ts) is the one builder of the sync result, forcraftar mcpandcraftar ui. A discarded orphan-drift readshand-edited orphan: discarded(DISCARDED_ORPHAN, the wordsdrift discardprints). Every other removal keeps spec 41'sorphanReason.orphanDriftBody(src/core/report.ts) is the one reader of an orphan-drift body, used bydrift showand the page.drift show's bytes were pinned before the change.mcp allow-writes/revoke-writes, andopenWorldHinton the writing tools.Ship notes
curlwas run against a realcraftar ui --port 0 --allow-writeson a synthetic workspace: 403 with noOrigin, 415, 409 with no echo, a drift discard, a stale digest refused, a sync, and SIGINT exiting 0. Windows was not run by hand.craftar drift discarddoes.413is sent and the connection closed. Destroying it at once reset the connection on Windows before the answer was read; the first CI run failed there. A test asserts the order (endbefore the response) and fails against the old server on Linux too.apply()after its first write answers500 internal error, as every failure of ours does; the page is not told which files were written (the terminal gets the first line).Content-Typeis compared case-insensitively (a media type is), where spec §6.3 says "exactly".diffroute keeps its words for an orphan thatagents-md.primarymade (spec 41 §4.8), now pinned by a test.node-clirule and reviewer'scraftar uibullet (POST under--allow-writes, the §6.3 order) together with thestatusDigestsentence.Test plan
npm run typecheck: passnpm run build: passnpx vitest run --exclude test/ci.test.ts --maxWorkers=6: 154 files passed (1 skipped), 3633 tests passed, 11 skipped. The oracle was skipped (no fixture in the worktree); no emitter,plan(),status()orapply()code changes.1653ae9clean.test/ui-writes-pins.test.ts(the read-only page and answers),test/write-pins.test.ts, thedrift showpins.1653ae9)