diff --git a/builder/src/main.rs b/builder/src/main.rs index b212989b..23b53048 100644 --- a/builder/src/main.rs +++ b/builder/src/main.rs @@ -690,7 +690,7 @@ fn run_extensions_build( let distflag = if dist { "--minify" } else { "--sourcemap" }; // The NAPI build. - let mut napi_args = vec!["napi", "build", "--platform", "--output-dir", "src"]; + let mut napi_args = vec!["exec", "napi", "build", "--platform", "--output-dir", "src"]; if dist { napi_args.push("--release"); } @@ -701,7 +701,7 @@ fn run_extensions_build( target = tmp; napi_args.extend(["--target", &target]); } - run_script("npx", &napi_args, VSCODE_PATH, true)?; + run_script("pnpm", &napi_args, VSCODE_PATH, true)?; // Ensure the JavaScript data structures generated from Rust are up to date. run_cmd!( diff --git a/server/src/processing/cache-spec.md b/server/src/processing/cache-spec.md index 9028726a..49904036 100644 --- a/server/src/processing/cache-spec.md +++ b/server/src/processing/cache-spec.md @@ -142,9 +142,8 @@ example fragment tag, after cache hydration: `See Bazzy things, Zappy things`. A fragment's content by default includes the content of the current doc block and the content -of the following code/doc block; fragments are not allowed in Markdown documents -(in this case, the fragment content consists of an error message), though a -Markdown document may include a fragment defined elsewhere; see +of the following code/doc block. In a Markdown document, a fragment's extent +is instead defined by the document's structure; see . Fragments may include the `following` attribute to enclose a specific number of the following code/doc blocks; for example, `` includes the current doc @@ -222,165 +221,129 @@ things`: Implementation of Fragments and gather elements -

Inline inclusion of fragments

- -A gather element lists fragment content in a separate block, laid out like the -source it came from. An inline inclusion instead inserts the *text* of a -fragment into the surrounding content, where it takes on the formatting of its -context: included in a heading, the fragment's text becomes part of that -heading; included in a list item, part of that item. The syntax is ``, where `ref` is the `id` of a `Fragment` (the name is -provisional; see the open questions). The element allows no attribute except -`ref`; all others are silently stripped during hydration. As for ``, -content written inside an `` in the source is moved after its closing -tag during hydration; the content which hydration places inside it is discarded -by dehydration. - -An `` may appear in any document, including a Markdown document. A -Markdown document can't define fragments (see -), but it can include one from a source file: -this lets a README or user guide quote the documentation kept beside the code -it describes, instead of a copy which drifts out of date. - -For example, a source file contains this doc block, followed by a code block: - -```c -// #### Install the *tools* -// -// -``` +

Fragments in Markdown documents

+ +A `` may be defined in a Markdown document as well as in a source +file. The rules below replace the source-file rules in + for fragment extent, what `following` counts, +what `following="0"` contains, clamping `following`, and gather-list layout. +All other rules in that section apply unchanged. + +### Fragment boundaries + +Boundaries are computed on the HTML translated from Markdown, before cache +hydration. + +* A *top-level block* is an element child of that HTML's root. Whitespace-only + text between blocks is ignored. Examples include paragraphs, headings, + lists (with all their items), tables, block quotes, code blocks, thematic + breaks, and elements written in raw HTML. One raw HTML block in the Markdown + may therefore produce several top-level blocks. +* A *heading* is an `

`-`

` top-level block, whether written in Markdown + or HTML. Gather elements written as headings therefore count as headings. +* The *anchor block* is the top-level block which contains the `` + tag. A tag inside a list item, table cell, or block quote anchors to the + whole list, table, or block quote. + +A fragment's extent is: + +* **Without `following`: the section which contains the anchor block.** The + section starts at the nearest heading at or before the anchor block and ends + just before the next heading of the same or a higher level (`#` is the + highest), or at the end of the document. If no heading precedes the anchor + block, the section runs from the start of the document to just before its + first heading of any level. +* **With `following="n"`: the anchor block and the next `n` top-level blocks**, + without treating headings as boundaries. `following` is clamped, and an + unparsable value is an error, as in a source file. + +The blocks in the extent are cleaned like any other fragment content (see +); in particular, `` tags are +removed, so a paragraph which held only the tag contributes nothing. A gather +element shows a Markdown fragment as a single doc block with no indent, +preceded by the line number of its first line. + +The extent depends only on the document's own source, so `Fragment::content` +stays in layer 3 (see ); no new layer or kind +of dependency is needed. + +### Interaction with gather elements + +* A gather element in any file may list fragments from Markdown documents and + source files alike. +* A gather element inside a fragment's extent is an error, as in a source file: + each gather element which lists that fragment shows an error message for it. + A gather heading at the same or a higher level than the section's heading is + not inside the section; it ends it. +* The `` tag hydrates to backlinks in place, exactly as in a source + file, and those backlinks are excluded from `Fragment::content` (layer 4). +* Extents may overlap or coincide; for example, two fragments without + `following` in the same section have the same content. -A Markdown document elsewhere in the project contains the heading `### Setup: -`. After cache hydration, this heading becomes: +### Errors -```html -

Setup: Install the tools

+This section adds no new error. The former rule that any fragment in a Markdown +document is an error is removed. The existing errors apply unchanged: a missing +or invalid `id`, a duplicate `id`, an unparsable `following`, and a gather +element inside the extent. An extent which is empty after cleaning, such as +`following="0"` on a paragraph holding only the tag, is not an error; it shows +no content, as an empty doc block does in a source file. + +### Saving and reopening + +Boundaries aren't stored. They're recomputed from the saved Markdown each time +the document is translated, so the saved source holds only the `` tag +the user wrote. Dehydration removes the backlinks and `contenteditable`, as in a +source file, and the Faithful translation mode of the HTML-to-Markdown +conversion keeps the tag verbatim as inline raw HTML. An `id="*"` is replaced +as described in auto-assignment of ids. + +The round trip must keep the tag in the same top-level block. In particular, a +paragraph which holds only a `` tag must be saved as its own +paragraph, not merged into a neighbor. Reopening the file then reproduces the +same extent. Edits which add, remove, or change the level of a heading, or add +or remove blocks, change the extent on purpose. The resulting change to +`Fragment::content` outdates gather elements listing the fragment by the +existing rules. + +### Examples + +```markdown +Intro text. + +## Install + + + +Run `./bt install`. + +### Windows + +* Install `pwsh` first. +* Then rerun the command. + +## Run ``` -The `

` wrapper is dropped, since the host is already a heading; the `` -stays. The paragraph which held the `` tag is empty in the fragment's -content, since cleaning removed that tag, so it contributes nothing. - -### Choosing the included content - -The included content is built from the doc blocks of the fragment's content -(its `cc-fragment-doc-contents` elements), never from its layout wrappers -(`cc-fragment-*`, line numbers, indents) or its code blocks, which aren't doc -content. The *host* is the nearest block-level ancestor of the ``: a -heading, `p`, `li`, `td`, `blockquote`, and so on. Doc blocks and Markdown -documents are both Markdown, so an `` written alone on a line parses -as the only content of a `

`: an `` always has a host. - -1. **Block inclusion: the host is a `

` which is a direct child of its doc - block (or, in a Markdown document, of the document), and the `` is - its only non-whitespace content.** The fragment's doc content is inserted - unchanged, keeping its headings, lists, code fences, and so on. Since a `

` - can't contain block content, the host `

` is replaced by `

`, which holds the ``, - now empty, followed by that content. Heading levels are not rewritten. -2. **Inline inclusion: every other case** (the usual one: the `` sits - inside a heading, paragraph, or list item beside text). The content is - flattened to phrasing content, placed inside the ``: - * Block wrappers (`p`, `h1`-`h6`, `div`, `blockquote`) are unwrapped and - their children kept, so the host's formatting applies, not the source's. - Heading levels in the source are discarded: an `

` included in an - `

` is `

` text. - * Lists and tables are replaced by their text content, in document order, - separated by single spaces. - * The permitted content of an `` (see - ) is kept: inline formatting such as - `em`, `strong`, and `code`, inline math, and images. Links and - ``s are kept too, unless the `` has an `` ancestor - (in Markdown link text, for example), since links can't nest; there, - they are unwrapped and their content kept. - * Any other element, such as a diagram (`wc-mermaid`, `graphviz-graph`) or - an `iframe`, is omitted. - * Blocks left empty by these rules are dropped. Where unwrapping leaves two - blocks adjacent, a single space is inserted between them; `
` is kept. - Leading and trailing whitespace of the result is trimmed. - * A fragment with no doc content left by these rules produces an error - message. - -In both cases, each `` in the included content which hydrated to a link -is re-hydrated from its `data-content` so that it links from the including -file, exactly as a gather list does (layer 5 under -); an error message is kept as is. - -An `` in the optional content of an `` is removed when that -content is cleaned, as a `` is. - -### Hydrated form and dehydration - -The hydrated form always keeps the `` element, so that -dehydration can recover `ref`, as an `` keeps its own: - -* Inline inclusion: `(content) - `, in place. -* Block inclusion: `
(content)
`, in place of the host `

`. -* An error: `(message)`, in place, in either case. - -Dehydration removes the content and the `contenteditable` attribute of each -``, and replaces each `div.cc-include` with a `

` holding only its -``. The saved source is therefore the `` -the user wrote. In a Markdown document or doc block, this is inline raw HTML, -which the Faithful translation mode of the HTML-to-Markdown conversion keeps -verbatim, as it does an ``. - -The Client must preserve the element: its TinyMCE configuration declares -`include` an inline custom element (`~include`) allowing the `contenteditable` -and `ref` attributes, as it does `xref`, and allows the `cc-include` class on a -`div`. The Server's sanitizer allowlist gains the same element, attributes, and -class. +* `intro`: no heading precedes it, so it contains `Intro text.` and stops at + `## Install`. +* `install`: the whole `## Install` section, including `### Windows` and its + list, stopping at `## Run`. The paragraph which held the tag is empty after + cleaning. +* `bt`: only the paragraph “Run `./bt install`.”, keeping the code formatting. +* `win`: the whole two-item list, since the list is the anchor block. -### Errors +```markdown +## Design + +Rationale. + +

Notes

+``` -Each of these replaces the content of the `` with an error message, -shown wherever the include is; it never aborts hydration of the rest of the -file: - -* `ref` is missing or empty, or isn't a valid CSS identifier. -* `ref` is not found, is defined more than once, or names a target or gather - element rather than a fragment. -* The fragment's own content is an error message (for example, it contains a - gather element, or is a fragment in a Markdown document); that message is - shown unchanged. -* The fragment contains no doc content after the rules of inline inclusion - above. - -### Dependencies - -An include is a reference like a cross-reference: its file is added to the -`IdEntry::dependents` of `ref`, including while the id is `Missing`. A change to -the fragment's content, or to the id's `IdState`, outdates the file by the -existing rules, so no new outdating rule is needed. - -In terms of the layers under cache design: - -* Include hydration is layer 6: it depends on layers 1 and 3 only, and nothing - depends on it. Like gather-list hydration, it runs after the file's own - fragments are committed, so including a fragment from the same file, or - from within the same doc block, needs no special case. -* An `` inside a fragment is removed, along with its contents, when - `Fragment::content` is cleaned, as a `` is. Were it kept, fragment - A including fragment B, which includes A, would outdate each other forever; - with the removal, a change still travels at most two steps. The cost is that a - gather element doesn't show what a listed fragment includes. For the same - reason, a fragment which includes itself shows its own content without the - included text. -* Likewise, `Target::inner_html` removes includes, since a cross-reference - renders it inside an `
`: an `` to a heading containing an include - shows the heading without the included text. - -### Open questions - -* Whether to reuse `` itself instead of a new element. That would - conflict with the rules that a `` requires an `id`, allows no - content, and hydrates to backlinks. -* Whether a block inclusion should rewrite heading levels to fit the section - it's in. -* Whether included content links back to its source, as a gather list does. +* `design` contains the gather element `notes`, so every gather element listing + `design` shows an error for it. Writing `following="1"` instead limits it to + the heading and `Rationale.`. Search (future work) -------------------- @@ -442,10 +405,6 @@ lower-numbered layers: everything about a target which this reads is embedded in the fragment's content, so any change to it also changes that content, which outdates the gathering file. -6. `` hydration depends on layers 1 and 3, re-hydrating each `` - in the included content as layer 5 does; see - . An `` is removed from both - layers, so no cached state depends on this one. Only layers 1 and 3 are cached, and layer 3 depends only on layer 1 through layer 2. So a change travels at most two steps (C → B → A), which matches the @@ -456,8 +415,8 @@ to track dependents of an id, so that files containing these dependencies can be marked `Outdated` (see below); these are sent to the `Cache::consumer_tx` channel for processing. Dependencies are tracked at file granularity, on the id rather than on the item defining it: `IdEntry::dependents` is the set of files -whose rendered output depends on this id, by any means -- an ``, -an ``, or a `data-gather` list naming it. One uniform set +whose rendered output depends on this id, by either means -- an +`` or a `data-gather` list naming it. One uniform set suffices in all three `IdState`s because the typical action taken on a dependent is marking this file outdated (fragments also use their dependents to generate "See x" links). diff --git a/submission.md b/submission.md index 0c4ef7fc..ffadb076 100644 --- a/submission.md +++ b/submission.md @@ -154,3 +154,99 @@ TODO: describe the review rounds. ### Last review (10 points) TODO: paste the model, effort, prompt, and output of the last review. + +Team member: Dustin Johnson (GitHub: drj228) +------------------------------------------ + +### Contribution (5 points) + +Fixed and verified the Windows build and standalone editor, and used Claude reviews to correct the specification to define Markdown fragments, address boundary and consistency findings, and reach zero necessary corrections. + +### Build and run check (5 points) + +ChatGPT assisted with troubleshooting and reviewed the terminal output and screenshots; Dustin executed the commands on Windows. + +Environment: Rust 1.99.1, Cargo 1.99.1, Node.js v26.14.0, npm 11.21.3. + +The initial installation was blocked at the cargo-binstall bootstrap by antivirus protection. Installed cargo-nextest directly using `cargo install cargo-nextest --locked`. + +The build then failed when npx invoked the NAPI launcher. Switching the build helper to `pnpm exec napi build` resolved the failure (commit `6a8cbc2`). + +`cargo run --manifest-path .\builder\Cargo.toml -- build` completed successfully, including the Rust workspace, client bundles, VS Code native extension, and TypeScript checks. All 13 export_bindings tests passed on both invocations; the other 196 tests were filtered out. + +Started `.\target\debug\codechat-editor-standalone.exe --port 8080 serve` and verified that the browser displayed the file browser and rendered README.md in the CodeChat editor. The full test suite was not run. + +### Review rounds (10 points) + +Reviewed with Claude Opus 5.5, Medium effort, in a separate browser session. +Round numbering continues the team's round 1 recorded above; Dustin requested +rounds 2-4. The earlier reviews and contributions above are historical records +of the superseded inline-inclusion proposal and have been preserved. + +| Round | Findings | Main changes made | +| ----- | -------- | ----------------- | +| 2 | 7 necessary (3 major, 2 medium, 2 minor); 5 optional | Replaced the out-of-scope inline-inclusion proposal with Markdown fragment definitions, section and block-count boundaries, gather interactions, layout, save/reopen rules, and examples; removed the Markdown-fragment ban and include-specific cache rules. | +| 3 | 3 necessary (1 medium, 2 minor); 4 optional | Defined boundaries on HTML before hydration, explicitly listed the source-file rules being replaced, and corrected the formatted example and overlap statement. | +| 4 | 0 necessary; 6 optional (4 carried over, 2 new) | Confirmed N1-N3 were resolved; made no further changes and left the optional suggestions unadopted. | + +ChatGPT prepared the targeted patch for the round 3 corrections; Dustin applied +it locally before requesting round 4. These were specification reviews, not +implementation verification of the proposed Markdown fragment feature. + +### Last review (10 points) + +Model: Claude Opus 5.5. Effort: Medium. Tool: Claude in a separate browser +session. Input: the corrected `server/src/processing/cache-spec.md`. + +Exact prompt: + +```text +Review only the corrected "Fragments in Markdown documents" section and its direct interactions with existing rules. Do not edit anything. + +Confirm whether N1, N2, and N3 are resolved. Report any remaining necessary corrections together. Keep optional suggestions separate and do not expand the scope. + +Do not claim implementation or test results. Finish with finding counts and a concise review-table summary. +``` + +Exact response: + +> N1, N2 and N3 are all resolved, and I found no new necessary corrections. This is a review only: I didn't edit anything and made no claims about implementation or tests. +> +> ### Status of the previous findings +> +> | Finding | Status | Where | +> | -------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +> | **N1:** blocks and headings were defined partly on the Markdown and partly on the HTML | Resolved | Lines 234–243 now compute boundaries on the HTML translated from the Markdown, before cache hydration. Blocks are the root's element children, whitespace between them is ignored, and a heading is any top-level `

`–`

`. That settles `following` counts and HTML gather headings. It also matches "depends only on the document's own source" (line 266) and "recomputed from the saved Markdown" (line 294). | +> | **N2:** the section didn't list every existing rule it replaces | Resolved | Lines 227–230 name all five: extent, what `following` counts, what `following="0"` contains, clamping, and gather-list layout. | +> | **N3:** two statements were wrong | Resolved | The `bt` example keeps its code formatting (line 333). The overlap statement now applies only to fragments without `following` (lines 280–281). | +> +> I rechecked the examples under the new HTML-based definition and they still hold: +> +> - A tag written alone on its own line stays a paragraph. +> - `

` is a top-level heading, so `design` contains a gather element. +> - `following="1"` gives the heading plus `Rationale.`. +> - `win` anchors to the whole list. +> +> ### Remaining necessary corrections +> +> None. +> +> ### Optional suggestions +> +> These four from the last review haven't been adopted and are still optional: +> +> - **O1:** End a default section just before a gather element as well. This avoids errors in the common layout of a section with a nested "Implementation of …" gather heading. +> - **O2:** Add one sentence on why "text inside the tag" and "an end tag" weren't chosen. +> - **O3:** Pin down the line number shown in a gather list (line 264) as the source line where the extent begins, even if that block is empty after cleaning. +> - **O4:** Add an example showing that a nested heading such as `> ## Note` doesn't end a section. +> +> Two new ones: +> +> - **O5:** Line 237 covers whitespace-only text at the top level but not other stray text. A raw HTML block such as `
a
tail` leaves the text "tail" directly under the root, outside any block. One clause would close the gap, for example: "non-whitespace top-level text belongs to the preceding block." +> - **O6:** Line 333 uses curly quotes (“…”). The rest of the spec uses straight quotes or backticks. +> +> **Necessary findings: 0. Optional findings: 6 (4 carried over, 2 new).** +> +> | Round | Findings | Main changes recommended | +> | ----- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +> | 4 | N1–N3 from round 3 resolved; 0 necessary and 6 optional (4 carried over, 2 new). | No necessary changes. Optional: end sections before gather elements; explain why the other options weren't chosen; pin down the line number; add a nested-heading example; cover stray top-level text; use straight quotes. |