From a7efa3a71a982a9293289d06fdcd774e54f49266 Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:25:10 +0100 Subject: [PATCH 1/8] Move the src/ root files into core/, platform/ and their features --- .vscode/launch.json | 2 +- cli/understanding.mjs | 8 ++++---- cli/understanding/anchors.mjs | 4 ++-- cli/understanding/git.mjs | 2 +- cli/understanding/graderBackends.mjs | 2 +- docs/journey-list.md | 4 ++-- media/journey-home.js | 6 +++--- media/journey-layout.js | 4 ++-- skills/code-journey/scripts/journey.py | 6 +++--- src/app.ts | 12 ++++++------ src/ask/prompts.ts | 4 ++-- src/ask/run.ts | 8 ++++---- src/ask/settings.ts | 2 +- src/check/cliThread.ts | 2 +- src/check/cliWorker.ts | 2 +- src/check/concern.ts | 6 +++--- src/check/controller.ts | 8 ++++---- src/check/failures.ts | 2 +- src/check/grading.ts | 4 ++-- src/check/host.ts | 4 ++-- src/check/park.ts | 2 +- src/check/prompts.ts | 4 ++-- src/check/push.ts | 2 +- src/check/threadLink.ts | 2 +- src/check/threadText.ts | 2 +- src/check/threads.ts | 6 +++--- src/check/viewModel.ts | 4 ++-- src/check/wiring.ts | 6 +++--- src/check/writer.ts | 6 +++--- src/chords.ts | 2 +- src/{ => codeLinks}/beats.ts | 14 +++++++------- src/{ => codeLinks}/claudeChatLinks.ts | 2 +- src/{ => codeLinks}/codeLinkClick.ts | 10 +++++----- src/{ => codeLinks}/codeLinks.ts | 12 ++++++------ src/{ => codeLinks}/valueHints.ts | 14 +++++++------- src/{ => core/anchors}/anchor.ts | 2 +- src/{ => core/anchors}/compact.ts | 0 src/{ => core/anchors}/lineFollow.ts | 0 src/{ => core/anchors}/staleDiff.ts | 0 src/{ => core}/coalesced.ts | 0 src/{ => core}/codeBlocks.ts | 0 src/{ => core}/codeLinkText.ts | 2 +- src/{ => core/format}/journeyModel.ts | 0 src/{ => core/format}/noteModel.ts | 4 ++-- src/{ => core}/linkUri.ts | 0 src/{ => core}/linkifyAnswer.ts | 2 +- src/{ => core/list}/journeyList.ts | 2 +- src/{ => core/list}/match.ts | 0 src/{ => core}/panelWidth.ts | 0 src/{ => core}/paths.ts | 0 src/{ => core}/text.ts | 2 +- src/{ => core}/writing.ts | 2 +- src/extension.ts | 20 ++++++++++---------- src/journeys/codeGroup.ts | 2 +- src/journeys/journeys.ts | 10 +++++----- src/journeys/mapPanel.ts | 8 ++++---- src/journeys/steps.ts | 10 +++++----- src/journeys/tracker.ts | 18 +++++++++--------- src/marks/lights.ts | 4 ++-- src/notes/broken.ts | 4 ++-- src/notes/changedOnDisk.ts | 6 +++--- src/notes/create.ts | 14 +++++++------- src/notes/decorations.ts | 8 ++++---- src/notes/find.ts | 10 +++++----- src/notes/folder.ts | 8 ++++---- src/{ => notes}/identity.ts | 6 +++--- src/notes/location.ts | 12 ++++++------ src/notes/move.ts | 6 +++--- src/notes/pages.ts | 8 ++++---- src/notes/prompt.ts | 8 ++++---- src/notes/reply.ts | 8 ++++---- src/notes/reveal.ts | 8 ++++---- src/{ => notes}/seen.ts | 6 +++--- src/notes/sessions.ts | 2 +- src/notes/status.ts | 10 +++++----- src/{ => notes}/store.ts | 10 +++++----- src/notes/suggestion.ts | 4 ++-- src/notes/undo.ts | 4 ++-- src/notes/unread.ts | 8 ++++---- src/notes/which.ts | 4 ++-- src/{ => platform/agent}/claude.ts | 0 src/{ => platform/agent}/claudeCli.ts | 0 src/{ => platform}/checkout.ts | 2 +- src/{ => platform}/decorations.ts | 0 src/{ => platform}/devReload.ts | 0 src/{ => platform}/documents.ts | 0 src/{ => platform}/followEdits.ts | 2 +- src/{ => platform}/git.ts | 0 src/{ => platform}/gitRenames.ts | 0 src/{ => platform}/jsonFolder.ts | 2 +- src/{ => platform}/memento.ts | 0 src/{ => platform}/quickPick.ts | 0 src/{ => platform}/saveFailures.ts | 0 src/{ => platform}/symbolBlocks.ts | 2 +- src/{ => platform}/workspaceFs.ts | 0 src/podcast/listenView.ts | 2 +- src/podcast/load.ts | 6 +++--- src/podcast/player.ts | 2 +- src/refresh.ts | 4 ++-- src/sidebar/journeyRows.ts | 12 ++++++------ src/sidebar/journeysTree.ts | 4 ++-- src/sidebar/listModel.ts | 8 ++++---- src/sidebar/nodes.ts | 6 +++--- src/sidebar/notesFilter.ts | 4 ++-- src/sidebar/notesTree.ts | 4 ++-- src/sidebar/rowItems.ts | 10 +++++----- src/testApi.ts | 6 +++--- src/threads/comments.ts | 20 ++++++++++---------- src/threads/sync.ts | 8 ++++---- src/tour/askStep.ts | 2 +- src/tour/card.ts | 10 +++++----- src/tour/checkTour.ts | 2 +- src/tour/commands.ts | 2 +- src/tour/lenses.ts | 4 ++-- src/tour/mapMessages.ts | 6 +++--- src/tour/panelLayout.ts | 2 +- src/tour/pick.ts | 2 +- src/tour/refs.ts | 4 ++-- src/tour/stepText.ts | 6 +++--- src/{ => tour}/tutorialSpot.ts | 2 +- src/tour/walk.ts | 6 +++--- src/watch.ts | 14 +++++++------- src/write/claudeRun.ts | 6 +++--- src/write/inProgress.ts | 4 ++-- src/write/rank.ts | 6 +++--- src/write/refreshJourney.ts | 8 ++++---- src/write/requests.ts | 6 +++--- src/write/writeJourney.ts | 6 +++--- test/anchor.test.ts | 6 +++--- test/answerLinks.test.ts | 4 ++-- test/claude.test.ts | 2 +- test/coalesced.test.ts | 2 +- test/codeBlocks.test.ts | 2 +- test/codeLinkText.test.ts | 4 ++-- test/compact.test.ts | 4 ++-- test/fixtures/journeyList.ts | 4 ++-- test/git.test.ts | 2 +- test/gitRenames.test.ts | 2 +- test/golden-journey.test.ts | 8 ++++---- test/golden-notes.test.ts | 8 ++++---- test/golden-podcast.test.ts | 2 +- test/integration/check/journeysView.ts | 2 +- test/integration/main/animation.ts | 2 +- test/integration/main/journeyFiles.ts | 2 +- test/integration/main/journeyMarks.ts | 2 +- test/integration/main/journeyTour.ts | 2 +- test/integration/main/keysAndMap.ts | 2 +- test/integration/main/listenEditor.ts | 2 +- test/integration/main/notes.ts | 4 ++-- test/integration/main/notesReview.ts | 2 +- test/integration/main/repoJourneys.ts | 2 +- test/integration/main/requests.ts | 4 ++-- test/integration/main/shared.ts | 2 +- test/integration/main/writeJourney.ts | 2 +- test/journey-list/shoot.mjs | 4 ++-- test/journey-map/harness.html | 2 +- test/journey-map/shoot.mjs | 4 ++-- test/journeyList.test.ts | 4 ++-- test/journeyModel.test.ts | 4 ++-- test/journeySteps.test.ts | 6 +++--- test/layout.test.ts | 2 +- test/lineFollow.test.ts | 2 +- test/match.test.ts | 2 +- test/noteModel.test.ts | 4 ++-- test/paths.test.ts | 2 +- test/tourStepText.test.ts | 2 +- test/workspaceFs.test.ts | 4 ++-- test/writing.test.ts | 2 +- 168 files changed, 374 insertions(+), 374 deletions(-) rename src/{ => codeLinks}/beats.ts (94%) rename src/{ => codeLinks}/claudeChatLinks.ts (99%) rename src/{ => codeLinks}/codeLinkClick.ts (93%) rename src/{ => codeLinks}/codeLinks.ts (97%) rename src/{ => codeLinks}/valueHints.ts (91%) rename src/{ => core/anchors}/anchor.ts (98%) rename src/{ => core/anchors}/compact.ts (100%) rename src/{ => core/anchors}/lineFollow.ts (100%) rename src/{ => core/anchors}/staleDiff.ts (100%) rename src/{ => core}/coalesced.ts (100%) rename src/{ => core}/codeBlocks.ts (100%) rename src/{ => core}/codeLinkText.ts (98%) rename src/{ => core/format}/journeyModel.ts (100%) rename src/{ => core/format}/noteModel.ts (98%) rename src/{ => core}/linkUri.ts (100%) rename src/{ => core}/linkifyAnswer.ts (98%) rename src/{ => core/list}/journeyList.ts (99%) rename src/{ => core/list}/match.ts (100%) rename src/{ => core}/panelWidth.ts (100%) rename src/{ => core}/paths.ts (100%) rename src/{ => core}/text.ts (98%) rename src/{ => core}/writing.ts (98%) rename src/{ => notes}/identity.ts (94%) rename src/{ => notes}/seen.ts (97%) rename src/{ => notes}/store.ts (98%) rename src/{ => platform/agent}/claude.ts (100%) rename src/{ => platform/agent}/claudeCli.ts (100%) rename src/{ => platform}/checkout.ts (97%) rename src/{ => platform}/decorations.ts (100%) rename src/{ => platform}/devReload.ts (100%) rename src/{ => platform}/documents.ts (100%) rename src/{ => platform}/followEdits.ts (98%) rename src/{ => platform}/git.ts (100%) rename src/{ => platform}/gitRenames.ts (100%) rename src/{ => platform}/jsonFolder.ts (98%) rename src/{ => platform}/memento.ts (100%) rename src/{ => platform}/quickPick.ts (100%) rename src/{ => platform}/saveFailures.ts (100%) rename src/{ => platform}/symbolBlocks.ts (99%) rename src/{ => platform}/workspaceFs.ts (100%) rename src/{ => tour}/tutorialSpot.ts (97%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1dc2c88..aa03552 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,7 @@ { // Press F5: a second window (the "Extension Development Host") opens on the example workspace (examples/shop), // running Code Notes straight from this folder: nothing is installed. While it runs, the extension is rebuilt on - // every save and that window reloads itself (src/devReload.ts). + // every save and that window reloads itself (src/platform/devReload.ts). "version": "0.2.0", "configurations": [ { diff --git a/cli/understanding.mjs b/cli/understanding.mjs index a477eee..b27b187 100755 --- a/cli/understanding.mjs +++ b/cli/understanding.mjs @@ -64,7 +64,7 @@ const cliName = (repo) => { // Running git: `git`/`gitOk` (synchronous, for reading), `gitRun` (asynchronous, for commit and push: no credential // prompt, a timeout); the branch, its base, a stack's parent, a stash. The extension has its own runner for its own -// git calls (src/git.ts); what it reads through this file runs these on a worker thread (src/check/cliWorker.ts). +// git calls (src/platform/git.ts); what it reads through this file runs these on a worker thread (src/check/cliWorker.ts). export function git(repo, args, opts = {}) { return execFileSync('git', args, { cwd: repo, encoding: 'utf8', maxBuffer: 64 << 20, stdio: ['ignore', 'pipe', 'pipe'], ...opts }) @@ -1129,7 +1129,7 @@ export function stamp(check, cfg) { // ---------- anchors.mjs ---------- // Compact anchors: a question's lines found again after the code moved. The same format and rules as the -// extension's src/compact.ts (written in another language; test/compact.test.ts and test/cli check each side). +// extension's src/core/anchors/compact.ts (written in another language; test/compact.test.ts and test/cli check each side). const norm = (s) => s.replace(/\s+/g, '').replace(/['`]/g, '"').replace(/[;,]+$/, '') const blank = (s) => norm(s) === '' @@ -1170,7 +1170,7 @@ function backward(lines, e, want, floor) { } /** * Where a compact anchor's code is now (0-based `{ start, end, fresh }`), or undefined when it is gone. `hint`: where - * it was. The rules of the extension's findCompact (src/compact.ts): head and tail found in order, an exact hash + * it was. The rules of the extension's findCompact (src/core/anchors/compact.ts): head and tail found in order, an exact hash * first, then the closest length, then the context lines, then the nearest place. Both sides run the same cases * (test/fixtures/compact-cases.json). */ @@ -1600,7 +1600,7 @@ const GRADER_MAX_TOKENS = 4000 const GRADER_TIMEOUT_MS = 300_000 /** - * The `claude` to run: UNDERSTANDING_CLAUDE, else `claude` on PATH. The extension finds its own (src/claudeCli.ts: + * The `claude` to run: UNDERSTANDING_CLAUDE, else `claude` on PATH. The extension finds its own (src/platform/agent/claudeCli.ts: * the codeNotes.claude.path setting, else the newest install on PATH and the usual places) and grades with it; this one * is for `grade` in a terminal, so the two can differ when several are installed. This file has no dependencies and * reads no VS Code setting, so it doesn't share the extension's search. diff --git a/cli/understanding/anchors.mjs b/cli/understanding/anchors.mjs index a76b7be..a88bcef 100644 --- a/cli/understanding/anchors.mjs +++ b/cli/understanding/anchors.mjs @@ -1,5 +1,5 @@ // Compact anchors: a question's lines found again after the code moved. The same format and rules as the -// extension's src/compact.ts (written in another language; test/compact.test.ts and test/cli check each side). +// extension's src/core/anchors/compact.ts (written in another language; test/compact.test.ts and test/cli check each side). import { createHash } from 'node:crypto' import fs from 'node:fs' import path from 'node:path' @@ -43,7 +43,7 @@ function backward(lines, e, want, floor) { } /** * Where a compact anchor's code is now (0-based `{ start, end, fresh }`), or undefined when it is gone. `hint`: where - * it was. The rules of the extension's findCompact (src/compact.ts): head and tail found in order, an exact hash + * it was. The rules of the extension's findCompact (src/core/anchors/compact.ts): head and tail found in order, an exact hash * first, then the closest length, then the context lines, then the nearest place. Both sides run the same cases * (test/fixtures/compact-cases.json). */ diff --git a/cli/understanding/git.mjs b/cli/understanding/git.mjs index 3441dcc..ffa17e3 100644 --- a/cli/understanding/git.mjs +++ b/cli/understanding/git.mjs @@ -1,6 +1,6 @@ // Running git: `git`/`gitOk` (synchronous, for reading), `gitRun` (asynchronous, for commit and push: no credential // prompt, a timeout); the branch, its base, a stack's parent, a stash. The extension has its own runner for its own -// git calls (src/git.ts); what it reads through this file runs these on a worker thread (src/check/cliWorker.ts). +// git calls (src/platform/git.ts); what it reads through this file runs these on a worker thread (src/check/cliWorker.ts). import { execFileSync, spawn } from 'node:child_process' import { DIR } from './constants.mjs' import { isHex } from './validate.mjs' diff --git a/cli/understanding/graderBackends.mjs b/cli/understanding/graderBackends.mjs index 1160376..ae059b0 100644 --- a/cli/understanding/graderBackends.mjs +++ b/cli/understanding/graderBackends.mjs @@ -13,7 +13,7 @@ const GRADER_MAX_TOKENS = 4000 const GRADER_TIMEOUT_MS = 300_000 /** - * The `claude` to run: UNDERSTANDING_CLAUDE, else `claude` on PATH. The extension finds its own (src/claudeCli.ts: + * The `claude` to run: UNDERSTANDING_CLAUDE, else `claude` on PATH. The extension finds its own (src/platform/agent/claudeCli.ts: * the codeNotes.claude.path setting, else the newest install on PATH and the usual places) and grades with it; this one * is for `grade` in a terminal, so the two can differ when several are installed. This file has no dependencies and * reads no VS Code setting, so it doesn't share the extension's search. diff --git a/docs/journey-list.md b/docs/journey-list.md index bf979eb..e6c2645 100644 --- a/docs/journey-list.md +++ b/docs/journey-list.md @@ -46,7 +46,7 @@ the panel home at 320/600/1000 px and the sidebar; measure overflow/clipping; ca ## As built (0.24.0) -- Model: `src/journeyList.ts` (`buildList`): rows with `area`, `age`, `here`, `meta`, search hits; the panel's +- Model: `src/core/list/journeyList.ts` (`buildList`): rows with `area`, `age`, `here`, `meta`, search hits; the panel's `sections` and the sidebar's `groups` come from the same call. Search: every word must match (title, question, summary, step titles, file paths; title hits weigh most; a light stem lets "retry" find "retries"). - On the panel each row is listed once: Continue, In , Checks and New come first; the area sections hold the @@ -94,7 +94,7 @@ the panel home at 320/600/1000 px and the sidebar; measure overflow/clipping; ca replaces the journey file and a notice offers **Show changes** (a diff). No note is written and nothing is said in the reader's name. From the preview or the row it refreshes that journey; the command's picker preselects only the journey in front (the walk, the panel's), never the first in the list. -- **Lenses:** one per function. Functions come from `src/codeBlocks.ts`: the language's symbols (functions, +- **Lenses:** one per function. Functions come from `src/core/codeBlocks.ts`: the language's symbols (functions, methods, classes; never what is nested in a function, so a destructuring or a callback is part of it), else the text (indentation and braces) while a language server is still starting. A step on the comment just above a function belongs to it; a file's top-level consts share one lens. The picker lists one row per journey. diff --git a/media/journey-home.js b/media/journey-home.js index c2c4c9d..23fef1c 100644 --- a/media/journey-home.js +++ b/media/journey-home.js @@ -1,6 +1,6 @@ // The journey panel's home: every journey of the workspace, to find one and walk it (docs/journey-list.md). Search, // filter chips, sections, a preview of the selected journey (beside the list when wide, unfolded under its row when -// narrow). The extension computes the list (src/journeyList.ts) with this home's search, filter and sort; we draw it. +// narrow). The extension computes the list (src/core/list/journeyList.ts) with this home's search, filter and sort; we draw it. // Needs common.js; styles in journey-home.css. Made by journey-map.js, which draws it in place of the journey while it // is in front: // const home = JourneyHome({ app, post(m), render(), walk(key), hasJourney(), isTutorialUp() }) @@ -10,7 +10,7 @@ ;(function () { const { el, button, baseName, runKey, itemAt, rovingKeys } = window.common - /** The orders the list can be sorted in (src/journeyList.ts sorts); `best` only while searching. */ + /** The orders the list can be sorted in (src/core/list/journeyList.ts sorts); `best` only while searching. */ const SORTS = [ ['best', 'Best match'], ['area', 'By area'], @@ -82,7 +82,7 @@ /** In front (the list over the journey), or not. */ let on = false - /** The list's model (src/journeyList.ts) and the journeys as the tour message lists them (`here`: the one open). */ + /** The list's model (src/core/list/journeyList.ts) and the journeys as the tour message lists them (`here`: the one open). */ let model let list = [] /** The query and filter chip, sent to the extension, which answers with a new model. */ diff --git a/media/journey-layout.js b/media/journey-layout.js index 229b64a..b4df0f8 100644 --- a/media/journey-layout.js +++ b/media/journey-layout.js @@ -8,8 +8,8 @@ // ancestors(byId, id), titleEl(n), leafEl(n, nums), samples(edge), pathD(points), curveD(bez), verb(label) } ;(function () { const { el, overlapArea, edgesOf } = window.common - // out/src/journeyModel.js is a CommonJS module the page loads as a plain script: it fills the `exports` object the - // page declares, also named JourneyModel (src/journeys/mapPanel.ts, test/journey-map/harness.html). + // out/src/core/format/journeyModel.js is a CommonJS module the page loads as a plain script: it fills the `exports` + // object the page declares, also named JourneyModel (src/journeys/mapPanel.ts, test/journey-map/harness.html). const JourneyModel = window.JourneyModel // ---------- an arrow's label: a plain verb phrase ---------- diff --git a/skills/code-journey/scripts/journey.py b/skills/code-journey/scripts/journey.py index eb86f7d..e4357d1 100755 --- a/skills/code-journey/scripts/journey.py +++ b/skills/code-journey/scripts/journey.py @@ -1517,7 +1517,7 @@ def check_ref(repo, ref): return '', [(a, ls[a - 1].strip()[:90])] + ([(b, ls[b - 1].strip()[:90])] if b > a else []) -# --- finding a step again after the code moved: the same rules as the extension (src/anchor.ts; +# --- finding a step again after the code moved: the same rules as the extension (src/core/anchors/anchor.ts; # keep the two in step). Lines compare without whitespace, with one quote style and no trailing ; or , (`norm`). def norm(s): return re.sub(r'[;,]+$', '', re.sub(r"['`]", '"', re.sub(r'\s+', '', s))) @@ -1532,7 +1532,7 @@ def weak(s): # `}` or `);` says nothing about where code is: # --- compact anchors (v3), as in docs/journey-format.md ("In the repo"); the extension does the same in -# src/compact.ts (keep the two in step). +# src/core/anchors/compact.ts (keep the two in step). def text_hash(text_lines, blanks=False): """sha1 of the non-blank lines through `norm`, joined by "\n" (compact.ts blockHash): a blank line added or removed is not a change. blanks=True: the other reading (every line, blank ones as ""), accepted when read.""" @@ -1919,7 +1919,7 @@ def repeat_warning(k, s): return '' -# --- step extras (format: media/journey-scene.js, src/codeLinkText.ts, src/valueHints.ts): a step's +# --- step extras (format: media/journey-scene.js, src/core/codeLinkText.ts, src/codeLinks/valueHints.ts): a step's # animation (`scene`), its code links (`links`: phrases of the lead/details that open the lines doing that part) and # its value hints (`values`: what a variable holds in the example run, above its line). Every line is read from the # source by the commands below; the author never types a line's text. diff --git a/src/app.ts b/src/app.ts index e12f53e..ef6300d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,16 +2,16 @@ // `provide`), the settings, and a few small helpers. Read anywhere; set only through `provide` and `setKey`. import * as vscode from 'vscode' -import { Beats } from './beats' +import { Beats } from './codeLinks/beats' import { CheckController } from './check/controller' -import { ClaudeLinks } from './claudeChatLinks' -import { CodeLinks } from './codeLinks' +import { ClaudeLinks } from './codeLinks/claudeChatLinks' +import { CodeLinks } from './codeLinks/codeLinks' import { Journeys } from './journeys/journeys' import { MapPanel } from './journeys/mapPanel' -import { Store } from './store' +import { Store } from './notes/store' import { TourItems } from './tour/walk' -import { TutorialSpot } from './tutorialSpot' -import { ValueHints } from './valueHints' +import { TutorialSpot } from './tour/tutorialSpot' +import { ValueHints } from './codeLinks/valueHints' /** The notes, and the stored state of this workspace (`state`) and of every workspace (`gstate`). */ export let store: Store diff --git a/src/ask/prompts.ts b/src/ask/prompts.ts index 9eef294..61c9a76 100644 --- a/src/ask/prompts.ts +++ b/src/ask/prompts.ts @@ -1,8 +1,8 @@ // What Claude is told when it answers a note: the note and its conversation, the rules, and the hints for a step's // question, an understanding check and the skills it may use. Only text: ask/run.ts sends it. -import { me } from '../identity' -import { Note } from '../store' +import { me } from '../notes/identity' +import { Note } from '../notes/store' import { UPDATE_ASK } from '../tour/askStep' /** How Claude works on a note and answers. */ diff --git a/src/ask/run.ts b/src/ask/run.ts index 8f1d53a..9f9812f 100644 --- a/src/ask/run.ts +++ b/src/ask/run.ts @@ -3,15 +3,15 @@ import * as vscode from 'vscode' import { byId, cfg, firstFolder, log, now, state, store, understanding } from '../app' -import { Ask, AskResult, modelProblem } from '../claude' +import { Ask, AskResult, modelProblem } from '../platform/agent/claude' import { shape, shapeOf } from '../notes/changedOnDisk' import { createNote } from '../notes/create' import { docUri, linesOfUri } from '../notes/location' import { reveal } from '../notes/reveal' import { refreshAll } from '../refresh' -import { markRead } from '../seen' -import { Note } from '../store' -import { plural } from '../text' +import { markRead } from '../notes/seen' +import { Note } from '../notes/store' +import { plural } from '../core/text' import { revealed, syncThread } from '../threads/sync' import { walk } from '../tour/instances' import { checkHint, claudePrompt, stepAskHint } from './prompts' diff --git a/src/ask/settings.ts b/src/ask/settings.ts index 28d88e3..188dcfd 100644 --- a/src/ask/settings.ts +++ b/src/ask/settings.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode' import { cfg, setCtx } from '../app' -import { findCli, findCliAsync } from '../claudeCli' +import { findCli, findCliAsync } from '../platform/agent/claudeCli' export const claudeMode = () => cfg().get('claude.mode', 'button') diff --git a/src/check/cliThread.ts b/src/check/cliThread.ts index 4da7516..e1c0c08 100644 --- a/src/check/cliThread.ts +++ b/src/check/cliThread.ts @@ -3,7 +3,7 @@ // Remote-SSH: the editor too) would wait with it. No vscode here: unit tests use it as is. import { Worker } from 'worker_threads' import * as path from 'path' -import { READ_ONLY_GIT } from '../git' +import { READ_ONLY_GIT } from '../platform/git' /** A call that takes longer than this is given up (a git that hangs): the worker is stopped, the next call starts a new one. */ const TIMEOUT_MS = 120_000 diff --git a/src/check/cliWorker.ts b/src/check/cliWorker.ts index 55ab591..2ea1f7c 100644 --- a/src/check/cliWorker.ts +++ b/src/check/cliWorker.ts @@ -7,7 +7,7 @@ import * as fs from 'fs' import * as os from 'os' import * as path from 'path' import { createHash } from 'crypto' -import { statusBranch, statusPaths } from '../git' +import { statusBranch, statusPaths } from '../platform/git' import { importCli } from './importCli' import type { RefreshResult } from './types' diff --git a/src/check/concern.ts b/src/check/concern.ts index bc42b44..99c6e6d 100644 --- a/src/check/concern.ts +++ b/src/check/concern.ts @@ -2,12 +2,12 @@ // can do about it: Suggest a fix (a note asked to Claude), Add TODO (a comment above the lines), Flag for review (on // the merge request), Dismiss (with a reason, or "I fixed it"). import * as vscode from 'vscode' -import type { Note } from '../store' +import type { Note } from '../notes/store' import { Check, Question } from './types' import { concernOf, samePerson, settledConcern, whoOf } from './concernState' import { commentMark, todoLines, todoPlace } from './todoComment' -import { gitOut } from '../git' -import { docLines } from '../documents' +import { gitOut } from '../platform/git' +import { docLines } from '../platform/documents' import type { CheckController } from './controller' export type ConcernAction = 'fix' | 'todo' | 'flag' | 'dismiss' | 'fixed' diff --git a/src/check/controller.ts b/src/check/controller.ts index c2aaad8..98d2ea5 100644 --- a/src/check/controller.ts +++ b/src/check/controller.ts @@ -14,14 +14,14 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' -import type { Note } from '../store' +import type { Note } from '../notes/store' import { Check, Cli, Link, notDone, QState, Question, RefreshResult, Status, Who, Words } from './types' import { linksAt, gradeMessageAt, gradedAttempts } from './threadText' import { concernOf } from './concernState' import { CheckView, checkView, definedOnly, runAction, statusText } from './viewModel' import { gradeFailure } from './failures' -import { Coalesced } from '../coalesced' -import { plural } from '../text' +import { Coalesced } from '../core/coalesced' +import { plural } from '../core/text' import { BackgroundQuestions } from './background' import { CliThread } from './cliThread' import { Concerns, ConcernAction, VIEW_CONCERN_ACTIONS } from './concern' @@ -39,7 +39,7 @@ import { CheckThreads } from './threads' import { CheckViewProvider } from './view' import type { CheckViewMessage, CheckViewMessageOf, CheckViewRequest } from './viewMessages' import { Writer } from './writer' -import { baseName } from '../paths' +import { baseName } from '../core/paths' export type { CheckHost } from './host' export { SESSION } from './constants' diff --git a/src/check/failures.ts b/src/check/failures.ts index 12821c6..7a1d5be 100644 --- a/src/check/failures.ts +++ b/src/check/failures.ts @@ -1,6 +1,6 @@ // What went wrong, in the Check view's plain words: writing the questions, grading an answer (by cause), a check file // that isn't JSON (where). No vscode API here (unit-tested in test/checkModel.test.ts). -import type { AskErrorKind } from '../claude' +import type { AskErrorKind } from '../platform/agent/claude' /** Where the engine's JSON error is, when it says so: "… (line 3 column 5)" (newer V8) or "… at position 42". */ const JSON_LINE_COL = /line (\d+) column (\d+)/ diff --git a/src/check/grading.ts b/src/check/grading.ts index 6ad63ca..a86feb5 100644 --- a/src/check/grading.ts +++ b/src/check/grading.ts @@ -2,8 +2,8 @@ // read-only; the verdict is written into the file and reaches the thread through the threads' sync. import * as vscode from 'vscode' import * as path from 'path' -import { Ask, AskErrorKind, AskResult } from '../claude' -import type { Note } from '../store' +import { Ask, AskErrorKind, AskResult } from '../platform/agent/claude' +import type { Note } from '../notes/store' import type { Attempt, Cli, Question } from './types' import { sameQuestion } from './threadLink' import { costOf } from './log' diff --git a/src/check/host.ts b/src/check/host.ts index 34a2b36..348020f 100644 --- a/src/check/host.ts +++ b/src/check/host.ts @@ -1,7 +1,7 @@ // What the understanding check needs from the rest of the extension (src/check/wiring.ts provides it), and the parts // of VS Code's git extension API it listens to. import * as vscode from 'vscode' -import type { Note, Store } from '../store' +import type { Note, Store } from '../notes/store' import type { Check } from './types' /** @@ -33,7 +33,7 @@ export interface NotesHost { /** Claude Code (writer.ts, grading.ts). */ export interface ClaudeHost { - /** The `claude` CLI (Claude Code; src/claudeCli.ts findCli), or undefined. Not the understanding CLI (controller's `cli`). */ + /** The `claude` CLI (Claude Code; src/platform/agent/claudeCli.ts findCli), or undefined. Not the understanding CLI (controller's `cli`). */ cli(): string | undefined /** Claude may run here (a trusted folder); says why not otherwise. */ allowed(what: string): boolean diff --git a/src/check/park.ts b/src/check/park.ts index 449ff8b..2ea7a4a 100644 --- a/src/check/park.ts +++ b/src/check/park.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' -import { gitOut } from '../git' +import { gitOut } from '../platform/git' import { RESTORED_OPEN_MS } from './constants' import type { CheckController } from './controller' diff --git a/src/check/prompts.ts b/src/check/prompts.ts index 178eea2..bfb1fe5 100644 --- a/src/check/prompts.ts +++ b/src/check/prompts.ts @@ -1,7 +1,7 @@ // What Claude is asked when it writes the check: the prompt for the questions, the prompt for the tour, and the // phase shown while it works (from its last tool call). No vscode API here (unit-tested in test/checkModel.test.ts). -import { READ_ONLY_TOOLS } from '../claude' -import type { ToolCall } from '../claude' +import { READ_ONLY_TOOLS } from '../platform/agent/claude' +import type { ToolCall } from '../platform/agent/claude' /** The prompt for `claude -p` that writes (or tops up) the questions with the understanding-check skill. */ export function checkPrompt(o: { skill: string; branch: string; baseRef: string; base: string; topUp: boolean; bundled: boolean; head?: string }): string { diff --git a/src/check/push.ts b/src/check/push.ts index 784ad8d..800e533 100644 --- a/src/check/push.ts +++ b/src/check/push.ts @@ -6,7 +6,7 @@ import * as path from 'path' import { concernOf, settledConcern } from './concernState' import { unsavedIn } from './unsaved' import { CommitPlan } from './viewModel' -import { gitOut } from '../git' +import { gitOut } from '../platform/git' import { PUSHED_MESSAGE_MS, REPO_FILES } from './constants' import type { CheckController } from './controller' diff --git a/src/check/threadLink.ts b/src/check/threadLink.ts index c8b9db2..617a94b 100644 --- a/src/check/threadLink.ts +++ b/src/check/threadLink.ts @@ -1,7 +1,7 @@ // A check thread's link to its question (in the note's `extra.check`): which check file, which question, and a hash // of the question's text when the thread was made. import { createHash } from 'crypto' -import type { Note } from '../store' +import type { Note } from '../notes/store' import { Question } from './types' import { questionBody } from './threadText' diff --git a/src/check/threadText.ts b/src/check/threadText.ts index fd86eed..a48ab4e 100644 --- a/src/check/threadText.ts +++ b/src/check/threadText.ts @@ -1,7 +1,7 @@ // A question's thread as text: the question (with the code it also depends on), the grader's replies, the code links // of each message, and the messages a thread is missing. No vscode API here (unit-tested in test/checkModel.test.ts). import type { Attempt, Link, Question, Range } from './types' -import { baseName } from '../paths' +import { baseName } from '../core/paths' /** The question as the first message of its thread; unchanged code it depends on (not linked from its words) below it. */ export function questionBody(q: Question): string { diff --git a/src/check/threads.ts b/src/check/threads.ts index 7a8eaf6..86ed3c2 100644 --- a/src/check/threads.ts +++ b/src/check/threads.ts @@ -3,9 +3,9 @@ // changed or went is removed (a thread never stands for a question it didn't show). import * as fs from 'fs' import * as path from 'path' -import { findCompact } from '../compact' -import { captureAnchor, type NoteData } from '../noteModel' -import type { Note } from '../store' +import { findCompact } from '../core/anchors/compact' +import { captureAnchor, type NoteData } from '../core/format/noteModel' +import type { Note } from '../notes/store' import { Attempt, Check, notDone, Question } from './types' import { gradeBody, missingMessages, questionBody, showsGrade } from './threadText' import { AUTHOR, SESSION } from './constants' diff --git a/src/check/viewModel.ts b/src/check/viewModel.ts index 0600ed4..9f8e781 100644 --- a/src/check/viewModel.ts +++ b/src/check/viewModel.ts @@ -1,12 +1,12 @@ // The Check view's model (what media/check.js and media/checkAnswer.js draw): where the check stands in the CLI's words, // the questions as rows, one button, the selected question's answer box, the tour; and the status bar item's text. // No vscode API here (unit-tested in test/checkModel.test.ts). -import { clock } from '../writing' +import { clock } from '../core/writing' import { concernOf, samePerson } from './concernState' import { SAY_IT_BACK, retryText } from './threadText' import { notDone } from './types' import type { Attempt, Kind, QState, Question, Range, Status, Who, Words } from './types' -import { baseName } from '../paths' +import { baseName } from '../core/paths' export const KIND_LABEL: Record = { how: 'How', why: 'Why', failure: 'Failure', edge: 'Edge case', change: 'Change' } diff --git a/src/check/wiring.ts b/src/check/wiring.ts index 384f4e0..cc7b227 100644 --- a/src/check/wiring.ts +++ b/src/check/wiring.ts @@ -6,15 +6,15 @@ import { byId, cfg, log, mapPanel, notes, now, provide, state, store, understand import { askAbout } from '../ask/run' import { claudeCli } from '../ask/settings' import { claudeAllowed } from '../ask/trust' -import { me } from '../identity' +import { me } from '../notes/identity' import { shape, shapeOf } from '../notes/changedOnDisk' import { newId } from '../notes/create' import { addReply } from '../notes/reply' import { focusReply, reveal } from '../notes/reveal' import { refreshAll } from '../refresh' -import { markRead, setSeen, unread } from '../seen' +import { markRead, setSeen, unread } from '../notes/seen' import { journeysTree } from '../sidebar/journeysTree' -import { Note } from '../store' +import { Note } from '../notes/store' import { noteOfThread, revealed } from '../threads/sync' import { currentTour, openCheckpoint, tourChanged } from '../tour/checkTour' import { walkJourney } from '../tour/commands' diff --git a/src/check/writer.ts b/src/check/writer.ts index 6bda93f..e8c4a84 100644 --- a/src/check/writer.ts +++ b/src/check/writer.ts @@ -5,9 +5,9 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as os from 'os' import * as path from 'path' -import { Ask, AskResult } from '../claude' -import { gitOut, statusPaths } from '../git' -import { clock } from '../writing' +import { Ask, AskResult } from '../platform/agent/claude' +import { gitOut, statusPaths } from '../platform/git' +import { clock } from '../core/writing' import { DEFAULT_MODEL_LABEL, ORPHAN_MAX_MS, SKILL, TICK_MS, WRITING_KEY } from './constants' import type { CheckController } from './controller' import { writeFailure } from './failures' diff --git a/src/chords.ts b/src/chords.ts index 971e9da..2f748b0 100644 --- a/src/chords.ts +++ b/src/chords.ts @@ -5,7 +5,7 @@ import { gstate, KEY, mapPanel, notes, PREFIX_KEY, setKey, understanding } from import { resolve } from './notes/status' import { stepUnread } from './notes/unread' import { pickNotes } from './notes/which' -import { unread } from './seen' +import { unread } from './notes/seen' import { checkStepping } from './check/wiring' import { walk } from './tour/instances' diff --git a/src/beats.ts b/src/codeLinks/beats.ts similarity index 94% rename from src/beats.ts rename to src/codeLinks/beats.ts index c33e5d5..bd0ee8d 100644 --- a/src/beats.ts +++ b/src/codeLinks/beats.ts @@ -1,11 +1,11 @@ import * as vscode from 'vscode' -import { setDecorations } from './decorations' -import { JBeat } from './journeyModel' -import { findLine } from './lineFollow' -import { TrackedLine, TrackedLines } from './followEdits' -import { showInCodeGroup, stepFileUri } from './journeys/codeGroup' -import { docLines } from './documents' -import { marksIn } from './marks/model' +import { setDecorations } from '../platform/decorations' +import { JBeat } from '../core/format/journeyModel' +import { findLine } from '../core/anchors/lineFollow' +import { TrackedLine, TrackedLines } from '../platform/followEdits' +import { showInCodeGroup, stepFileUri } from '../journeys/codeGroup' +import { docLines } from '../platform/documents' +import { marksIn } from '../marks/model' // A step's animation: the beat on screen lights the one line that does what it shows, nothing else // (values are the step's value hints: valueHints.ts). A beat with marks (tour/stepMarks.ts) leaves its line unboxed: diff --git a/src/claudeChatLinks.ts b/src/codeLinks/claudeChatLinks.ts similarity index 99% rename from src/claudeChatLinks.ts rename to src/codeLinks/claudeChatLinks.ts index d6372ae..08296d4 100644 --- a/src/claudeChatLinks.ts +++ b/src/codeLinks/claudeChatLinks.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import { setDecorations } from './decorations' +import { setDecorations } from '../platform/decorations' // Links from a chat with Claude Code to code ("[names what it commits](src/check.ts#L812-L830)"): the lines they open // are lit the way a journey's code links are, with "← Back" above them to where the reader was. diff --git a/src/codeLinkClick.ts b/src/codeLinks/codeLinkClick.ts similarity index 93% rename from src/codeLinkClick.ts rename to src/codeLinks/codeLinkClick.ts index 5fd8afc..f1f8766 100644 --- a/src/codeLinkClick.ts +++ b/src/codeLinks/codeLinkClick.ts @@ -1,11 +1,11 @@ // A code link clicked in a step card or a check thread: its code lit (the keyboard stays where the click was), and the // way back to the step or the question. (codeLinks.ts lights the code; codeLinkText.ts marks the phrases.) -import { codeLinks } from './app' -import { docUri } from './notes/location' -import { cardLine, stepUri } from './tour/stepPlace' -import { card, tourState, walk } from './tour/instances' -import { backToQuestion, checkLinkNote } from './check/wiring' +import { codeLinks } from '../app' +import { docUri } from '../notes/location' +import { cardLine, stepUri } from '../tour/stepPlace' +import { card, tourState, walk } from '../tour/instances' +import { backToQuestion, checkLinkNote } from '../check/wiring' /** After a click on a step's link, the cursor moving there for this long is the link's doing, not the person reading. */ const LINK_CURSOR_MS = 1500 diff --git a/src/codeLinks.ts b/src/codeLinks/codeLinks.ts similarity index 97% rename from src/codeLinks.ts rename to src/codeLinks/codeLinks.ts index 2c02a9f..ca75997 100644 --- a/src/codeLinks.ts +++ b/src/codeLinks/codeLinks.ts @@ -1,10 +1,10 @@ import * as vscode from 'vscode' -import { setDecorations } from './decorations' -import { fileLines } from './documents' -import type { StepLink } from './journeyModel' -import { findLine } from './lineFollow' -import { TrackedLine, TrackedLines } from './followEdits' -import { showInCodeGroup, stepFileUri } from './journeys/codeGroup' +import { setDecorations } from '../platform/decorations' +import { fileLines } from '../platform/documents' +import type { StepLink } from '../core/format/journeyModel' +import { findLine } from '../core/anchors/lineFollow' +import { TrackedLine, TrackedLines } from '../platform/followEdits' +import { showInCodeGroup, stepFileUri } from '../journeys/codeGroup' // Code links: a click on a linked phrase of the step's card lights that phrase's lines and brings them // into view. Nothing is marked before a click (VS Code tells an extension nothing about hovering a link in a comment, diff --git a/src/valueHints.ts b/src/codeLinks/valueHints.ts similarity index 91% rename from src/valueHints.ts rename to src/codeLinks/valueHints.ts index bfa570b..28bce39 100644 --- a/src/valueHints.ts +++ b/src/codeLinks/valueHints.ts @@ -1,11 +1,11 @@ import * as vscode from 'vscode' -import { fileLines } from './documents' -import { findLine } from './lineFollow' -import { capValue } from './journeys/textFormat' -import { TrackedLine, TrackedLines } from './followEdits' -import { stepFileUri } from './journeys/codeGroup' -import type { ValueHint } from './journeyModel' -import { baseName } from './paths' +import { fileLines } from '../platform/documents' +import { findLine } from '../core/anchors/lineFollow' +import { capValue } from '../journeys/textFormat' +import { TrackedLine, TrackedLines } from '../platform/followEdits' +import { stepFileUri } from '../journeys/codeGroup' +import type { ValueHint } from '../core/format/journeyModel' +import { baseName } from '../core/paths' // Value hints: while a step is open, a faint line right above the code where a value is declared or used // says what it holds in the example run: `objs = [Secret run-…, Pod run-…]`. Like a debugger's inline values, but diff --git a/src/anchor.ts b/src/core/anchors/anchor.ts similarity index 98% rename from src/anchor.ts rename to src/core/anchors/anchor.ts index bcdb964..3eef6f3 100644 --- a/src/anchor.ts +++ b/src/core/anchors/anchor.ts @@ -54,7 +54,7 @@ const DISTINCT = 25 /** * Where the anchor text occurs now. A candidate needs matching context, unless the anchor is substantial (2+ * non-blank lines, or one long line) and occurs exactly once: a short line like `return null` elsewhere is not the - * same code, but a unique `import { a, b } from './x.js'` that moved on its own (import sorting) is. + * same code, but a unique `import { a, b } from '../../x.js'` that moved on its own (import sorting) is. */ export function relocate(lines: string[], anchor: string[], before: string[], after: string[], hint: number): number | undefined { if (!anchor.length || anchor.every(blank)) return undefined diff --git a/src/compact.ts b/src/core/anchors/compact.ts similarity index 100% rename from src/compact.ts rename to src/core/anchors/compact.ts diff --git a/src/lineFollow.ts b/src/core/anchors/lineFollow.ts similarity index 100% rename from src/lineFollow.ts rename to src/core/anchors/lineFollow.ts diff --git a/src/staleDiff.ts b/src/core/anchors/staleDiff.ts similarity index 100% rename from src/staleDiff.ts rename to src/core/anchors/staleDiff.ts diff --git a/src/coalesced.ts b/src/core/coalesced.ts similarity index 100% rename from src/coalesced.ts rename to src/core/coalesced.ts diff --git a/src/codeBlocks.ts b/src/core/codeBlocks.ts similarity index 100% rename from src/codeBlocks.ts rename to src/core/codeBlocks.ts diff --git a/src/codeLinkText.ts b/src/core/codeLinkText.ts similarity index 98% rename from src/codeLinkText.ts rename to src/core/codeLinkText.ts index 77ad974..556323d 100644 --- a/src/codeLinkText.ts +++ b/src/core/codeLinkText.ts @@ -1,6 +1,6 @@ // Code links: a phrase of a step's text that is a link to the lines doing what it says. Pure, unit-tested. What a link // is in the journey file (StepLink, readLinks) is journeyModel.ts. -import type { StepLink } from './journeyModel' +import type { StepLink } from './format/journeyModel' import { baseName } from './paths' /** A markdown link (`[text](target)`) or a code span: a phrase inside one is left alone. */ diff --git a/src/journeyModel.ts b/src/core/format/journeyModel.ts similarity index 100% rename from src/journeyModel.ts rename to src/core/format/journeyModel.ts diff --git a/src/noteModel.ts b/src/core/format/noteModel.ts similarity index 98% rename from src/noteModel.ts rename to src/core/format/noteModel.ts index 6eb3c6d..3b3129a 100644 --- a/src/noteModel.ts +++ b/src/core/format/noteModel.ts @@ -3,7 +3,7 @@ // files themselves is store.ts. The README written for agents beside the notes is media/notes-README.md (agentReadme). import * as fs from 'fs' import * as path from 'path' -import { isAbsolutePath, slashPath } from './paths' +import { isAbsolutePath, slashPath } from '../paths' export type Role = 'human' | 'agent' export interface Message { author: string; body: string; at?: string; role?: Role } @@ -213,7 +213,7 @@ export function parseNote(raw: string, id: string): NoteData | string { } /** media/notes-README.md: the README with `${person}` and `${folder}` where agentReadme puts them. */ -const README_TEMPLATE = path.join(__dirname, '..', '..', 'media', 'notes-README.md') +const README_TEMPLATE = path.join(__dirname, '..', '..', '..', '..', 'media', 'notes-README.md') let readme: string | undefined /** The README the extension writes into the notes folder (named `folder`): the note format, for agents, naming `person`. */ diff --git a/src/linkUri.ts b/src/core/linkUri.ts similarity index 100% rename from src/linkUri.ts rename to src/core/linkUri.ts diff --git a/src/linkifyAnswer.ts b/src/core/linkifyAnswer.ts similarity index 98% rename from src/linkifyAnswer.ts rename to src/core/linkifyAnswer.ts index 35d47db..66535f7 100644 --- a/src/linkifyAnswer.ts +++ b/src/core/linkifyAnswer.ts @@ -2,7 +2,7 @@ // "(…)" and lists; absolute paths are shown repo-relative (never the home folder). No vscode API here (unit-tested in // test/answerLinks.test.ts). -import { PATH } from './journeys/textFormat' +import { PATH } from '../journeys/textFormat' const esc = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') diff --git a/src/journeyList.ts b/src/core/list/journeyList.ts similarity index 99% rename from src/journeyList.ts rename to src/core/list/journeyList.ts index 1624db4..fb9f24b 100644 --- a/src/journeyList.ts +++ b/src/core/list/journeyList.ts @@ -3,7 +3,7 @@ // No vscode API (the panel's tests load the compiled file as is): unit-tested in test/journeyList.test.ts. The search's // word matching is match.ts. import { matchScore, queryWords } from './match' -import { baseName } from './paths' +import { baseName } from '../paths' /** Only journeys are listed ('review': nothing makes one yet). 'check' is not listed: a check lives in the Check view. */ export type ListKind = 'journey' | 'check' | 'review' diff --git a/src/match.ts b/src/core/list/match.ts similarity index 100% rename from src/match.ts rename to src/core/list/match.ts diff --git a/src/panelWidth.ts b/src/core/panelWidth.ts similarity index 100% rename from src/panelWidth.ts rename to src/core/panelWidth.ts diff --git a/src/paths.ts b/src/core/paths.ts similarity index 100% rename from src/paths.ts rename to src/core/paths.ts diff --git a/src/text.ts b/src/core/text.ts similarity index 98% rename from src/text.ts rename to src/core/text.ts index 8ed0d0e..0c0b074 100644 --- a/src/text.ts +++ b/src/core/text.ts @@ -1,7 +1,7 @@ // Text as the lists, threads and messages show it: one line of markdown as plain text, a note's title and lines, // counts of things, ages, shortened questions. -import type { Note } from './store' +import type { Note } from '../notes/store' /** Links and images as their text: "[text](url)" -> "text". */ const stripLinks = (s: string) => s.replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1') diff --git a/src/writing.ts b/src/core/writing.ts similarity index 98% rename from src/writing.ts rename to src/core/writing.ts index 48afbb3..351db49 100644 --- a/src/writing.ts +++ b/src/core/writing.ts @@ -1,6 +1,6 @@ // Writing a journey with Claude: the prompt, the plain phase shown while it works, the clock. // No vscode API here (unit-tested in test/writing.test.ts). -import type { ToolCall } from './claude' +import type { ToolCall } from '../platform/agent/claude' /** "1:05" */ export function clock(ms: number): string { diff --git a/src/extension.ts b/src/extension.ts index 222b1a9..7b6f9ae 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,14 +7,14 @@ import { beats, cfg, claudeLinks, codeLinks, controller, extVersion, gstate, jou import { askClaudeCommand, cancelClaudeCommand } from './ask/commands' import { askStatusItem, createAskStatusItem, loadAskErrors } from './ask/run' import { watchClaudeCli } from './ask/settings' -import { Beats } from './beats' +import { Beats } from './codeLinks/beats' import { answerCheck, checkConcern, createUnderstanding, gradeCheck } from './check/wiring' import { next, prefixUsed, previous, resolveNext } from './chords' -import { ClaudeLinks } from './claudeChatLinks' -import { codeLinkBack, openCodeLink } from './codeLinkClick' -import { CodeLinks } from './codeLinks' -import { devReload } from './devReload' -import { initIdentity, me, rememberMe } from './identity' +import { ClaudeLinks } from './codeLinks/claudeChatLinks' +import { codeLinkBack, openCodeLink } from './codeLinks/codeLinkClick' +import { CodeLinks } from './codeLinks/codeLinks' +import { devReload } from './platform/devReload' +import { initIdentity, me, rememberMe } from './notes/identity' import { Journeys } from './journeys/journeys' import { MapPanel } from './journeys/mapPanel' import { openBroken, restoreBroken } from './notes/broken' @@ -36,11 +36,11 @@ import { undo } from './notes/undo' import { markAllRead, markUnread, stepUnread } from './notes/unread' import { pickNotes } from './notes/which' import { refreshAll } from './refresh' -import { markJourneysSeen, migrateSeen } from './seen' +import { markJourneysSeen, migrateSeen } from './notes/seen' import { createJourneysView, searchJourneys, journeysHereAll, sortJourneys } from './sidebar/journeysTree' import { groupByFile, groupBySession, hideResolvedNotes, loadGroupMode, pickFilter, showResolvedNotes } from './sidebar/notesFilter' import { createNotesView, rowsSelected, treeView } from './sidebar/notesTree' -import { Store } from './store' +import { Store } from './notes/store' import { testApi } from './testApi' import { collapseThread, expandThread } from './threads/comments' import { askStep, askUpdate } from './tour/askStep' @@ -51,8 +51,8 @@ import { registerRefPages } from './tour/refs' import { createCard, createTourItems, stepDetails, walk } from './tour/instances' import { podcasts } from './podcast/player' import { tutorial } from './tour/tutorial' -import { TutorialSpot } from './tutorialSpot' -import { ValueHints } from './valueHints' +import { TutorialSpot } from './tour/tutorialSpot' +import { ValueHints } from './codeLinks/valueHints' import { reloadAll, watchBranches, watchEditors, watchEdits, watchFiles, watchJourneys } from './watch' import { refreshJourney } from './write/refreshJourney' import { askQuestion, watchRequests } from './write/requests' diff --git a/src/journeys/codeGroup.ts b/src/journeys/codeGroup.ts index b70fd72..f0b99d4 100644 --- a/src/journeys/codeGroup.ts +++ b/src/journeys/codeGroup.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import { ownSelection } from '../claudeChatLinks' +import { ownSelection } from '../codeLinks/claudeChatLinks' // A step's code in the editor group beside the panel (the code group): where a file a step names is now, and showing // it there. Used by code links (codeLinks.ts), the beat's line (beats.ts) and value hints (valueHints.ts). diff --git a/src/journeys/journeys.ts b/src/journeys/journeys.ts index 270c6fe..61faae5 100644 --- a/src/journeys/journeys.ts +++ b/src/journeys/journeys.ts @@ -1,10 +1,10 @@ import * as vscode from 'vscode' -import { wfs } from '../workspaceFs' -import { isOldFormat, parseJourney } from '../journeyModel' -import { folderName, folderSetting } from '../store' -import { jsonFilesIn, jsonName, readText, watchJsonFiles } from '../jsonFolder' +import { wfs } from '../platform/workspaceFs' +import { isOldFormat, parseJourney } from '../core/format/journeyModel' +import { folderName, folderSetting } from '../notes/store' +import { jsonFilesIn, jsonName, readText, watchJsonFiles } from '../platform/jsonFolder' import { LoadedJourney, carryPositions, posKey, writtenAt } from './steps' -import { pathIn, settingFolder } from '../paths' +import { pathIn, settingFolder } from '../core/paths' import { StepTracker } from './tracker' import { isPodcastFile } from '../podcast/model' diff --git a/src/journeys/mapPanel.ts b/src/journeys/mapPanel.ts index b5ae086..5e7c464 100644 --- a/src/journeys/mapPanel.ts +++ b/src/journeys/mapPanel.ts @@ -1,11 +1,11 @@ import * as vscode from 'vscode' -import type { ListKind, ListModel, Sort } from '../journeyList' +import type { ListKind, ListModel, Sort } from '../core/list/journeyList' import type { StepCard } from '../tour/card' import { escapeHtml, webviewPage } from '../webview/page' -import { fileName } from '../jsonFolder' +import { fileName } from '../platform/jsonFolder' import { LoadedJourney } from './steps' import { journeysFolderName } from './journeys' -import { folderName } from '../store' +import { folderName } from '../notes/store' // The journey panel: one journey's map and storyline (or the Journeys list) in a webview beside the editor, and the // messages between it and media/journey-map.js. @@ -367,7 +367,7 @@ export class MapPanel implements vscode.Disposable { inline: 'var exports = {}; var JourneyModel = exports', // In this order: each of media/ needs the ones before it (its header says which). scripts: [ - file('out', 'src', 'journeyModel.js'), file('out', 'vendor', 'elk.bundled.js'), + file('out', 'src', 'core', 'format', 'journeyModel.js'), file('out', 'vendor', 'elk.bundled.js'), ...[ 'common', 'journey-layout', 'journey-farnames', 'journey-graph', 'code-paint', 'journey-scene', 'journey-scene-app', 'journey-home', 'journey-splitter', 'journey-tutorial', 'journey-podcast', 'journey-map', diff --git a/src/journeys/steps.ts b/src/journeys/steps.ts index 1b8d94f..668ad97 100644 --- a/src/journeys/steps.ts +++ b/src/journeys/steps.ts @@ -1,9 +1,9 @@ import type * as vscode from 'vscode' -import type { Journey, JStep } from '../journeyModel' -import { anchor } from '../anchor' -import { staleKind } from '../staleDiff' -import { AnyAnchor, compactOf, findCompact, isCompact, toCompact } from '../compact' -import { captureAnchor } from '../noteModel' +import type { Journey, JStep } from '../core/format/journeyModel' +import { anchor } from '../core/anchors/anchor' +import { staleKind } from '../core/anchors/staleDiff' +import { AnyAnchor, compactOf, findCompact, isCompact, toCompact } from '../core/anchors/compact' +import { captureAnchor } from '../core/format/noteModel' // A loaded journey and where its steps' code is now. No vscode API at run time (unit-tested in test/journeySteps.test.ts): // the tracker (tracker.ts) reads the files and keeps state; these say where a step is in the lines it got. diff --git a/src/journeys/tracker.ts b/src/journeys/tracker.ts index c0260a1..aceb392 100644 --- a/src/journeys/tracker.ts +++ b/src/journeys/tracker.ts @@ -1,13 +1,13 @@ import * as vscode from 'vscode' -import { fileLines, docLines } from '../documents' -import { JStep } from '../journeyModel' -import { Loc } from '../anchor' -import { LineEdit, shift, swallows } from '../lineFollow' -import { lineEdits } from '../followEdits' -import { AnyAnchor, CompactAnchor, Found, compactOf, findCompact, toCompact } from '../compact' -import { GitRenameCache } from '../gitRenames' -import { dirPath, pathIn } from '../paths' -import { Kept } from '../memento' +import { fileLines, docLines } from '../platform/documents' +import { JStep } from '../core/format/journeyModel' +import { Loc } from '../core/anchors/anchor' +import { LineEdit, shift, swallows } from '../core/anchors/lineFollow' +import { lineEdits } from '../platform/followEdits' +import { AnyAnchor, CompactAnchor, Found, compactOf, findCompact, toCompact } from '../core/anchors/compact' +import { GitRenameCache } from '../platform/gitRenames' +import { dirPath, pathIn } from '../core/paths' +import { Kept } from '../platform/memento' import { LoadedJourney, StepAt, atOf, captureStepAnchor, fileOf, isEmptyAnchor, placeStep, sameStepAt, stepOf, } from './steps' diff --git a/src/marks/lights.ts b/src/marks/lights.ts index 965a121..1127154 100644 --- a/src/marks/lights.ts +++ b/src/marks/lights.ts @@ -4,8 +4,8 @@ // is the one coloured thing on the code (codeNotes.markBackground); the marks before it a lighter, grey tint. import * as vscode from 'vscode' -import { setDecorations } from '../decorations' -import { docLines } from '../documents' +import { setDecorations } from '../platform/decorations' +import { docLines } from '../platform/documents' import { CodeMark, findMark, MarkSpot } from './model' /** What is lit in one document: ranges within lines, and whole lines, in each style. */ diff --git a/src/notes/broken.ts b/src/notes/broken.ts index 05aac83..8fdb121 100644 --- a/src/notes/broken.ts +++ b/src/notes/broken.ts @@ -3,9 +3,9 @@ import * as vscode from 'vscode' import { store } from '../app' -import { serialize } from '../noteModel' +import { serialize } from '../core/format/noteModel' import { Node } from '../sidebar/nodes' -import { wfs } from '../workspaceFs' +import { wfs } from '../platform/workspaceFs' /** Where in the file the problem `why` (store.ts's words) is: a field's name, the end (bad JSON), or the top. */ function problemAt(doc: vscode.TextDocument, why: string): vscode.Position { diff --git a/src/notes/changedOnDisk.ts b/src/notes/changedOnDisk.ts index 5b469c1..db33dae 100644 --- a/src/notes/changedOnDisk.ts +++ b/src/notes/changedOnDisk.ts @@ -2,11 +2,11 @@ // recorded, then everything refreshed and the notes re-anchored. import { log, notes, store } from '../app' -import { isAgent, mine } from '../identity' -import { Message, NoteEvent } from '../noteModel' +import { isAgent, mine } from './identity' +import { Message, NoteEvent } from '../core/format/noteModel' import { refreshAll } from '../refresh' import { lastMessage } from '../sidebar/nodes' -import { Note } from '../store' +import { Note } from './store' import { card, tourState, walk } from '../tour/instances' import { reanchorAll } from './location' import { addEvent, statusEvent } from './status' diff --git a/src/notes/create.ts b/src/notes/create.ts index 9010391..93b5e00 100644 --- a/src/notes/create.ts +++ b/src/notes/create.ts @@ -1,18 +1,18 @@ // New notes: on lines (the editor's comment box, or a one-line box), on a whole file or folder. import * as vscode from 'vscode' -import { Loc } from '../anchor' +import { Loc } from '../core/anchors/anchor' import { KEY, log, now, showError, store } from '../app' import { askClaude } from '../ask/run' import { askAlways, askOnQuestion } from '../ask/settings' -import { me } from '../identity' +import { me } from './identity' import { refreshAll } from '../refresh' -import { setSeen } from '../seen' -import { captureAnchor, NoteData } from '../noteModel' -import { folderName, Note } from '../store' +import { setSeen } from './seen' +import { captureAnchor, NoteData } from '../core/format/noteModel' +import { folderName, Note } from './store' import { anchorAt, inNotesFolder, otherAnchor, rangeLines, relPath, selectedLines } from './location' -import { diskLines, docLines } from '../documents' -import { wfs } from '../workspaceFs' +import { diskLines, docLines } from '../platform/documents' +import { wfs } from '../platform/workspaceFs' import { shape, shapeOf } from './changedOnDisk' import { allowComments } from './commentRanges' import { reveal } from './reveal' diff --git a/src/notes/decorations.ts b/src/notes/decorations.ts index 338d6f3..3ce1296 100644 --- a/src/notes/decorations.ts +++ b/src/notes/decorations.ts @@ -1,12 +1,12 @@ // How notes mark their lines in the editor: a bar for open and stale notes, the exact text a note is about, unread -// in the scrollbar. (src/decorations.ts sends each editor's decorations; the step card draws its own: tour/card.ts.) +// in the scrollbar. (src/platform/decorations.ts sends each editor's decorations; the step card draws its own: tour/card.ts.) import * as vscode from 'vscode' import { cfg } from '../app' -import { setDecorations } from '../decorations' -import { unread } from '../seen' +import { setDecorations } from '../platform/decorations' +import { unread } from './seen' import { hiddenInEditor } from '../sidebar/notesFilter' -import { Note } from '../store' +import { Note } from './store' import { card } from '../tour/instances' import { lineNotesFor } from './location' diff --git a/src/notes/find.ts b/src/notes/find.ts index 2c214c0..b567b3d 100644 --- a/src/notes/find.ts +++ b/src/notes/find.ts @@ -2,13 +2,13 @@ import * as vscode from 'vscode' import { notes } from '../app' -import { unread } from '../seen' +import { unread } from './seen' import { lastMessage, order } from '../sidebar/nodes' -import { Note } from '../store' -import { noteTitle, plain } from '../text' +import { Note } from './store' +import { noteTitle, plain } from '../core/text' import { reveal } from './reveal' -import { pickOne } from '../quickPick' -import { baseName } from '../paths' +import { pickOne } from '../platform/quickPick' +import { baseName } from '../core/paths' /** What a note's words are searched in: its file, session, and every message's author and text. */ const haystack = (n: Note) => [n.data.file, n.data.session ?? '', ...n.data.messages.flatMap((m) => [m.author, m.body])].join('\n').toLowerCase() diff --git a/src/notes/folder.ts b/src/notes/folder.ts index 3ef21ab..e76e043 100644 --- a/src/notes/folder.ts +++ b/src/notes/folder.ts @@ -4,10 +4,10 @@ import * as vscode from 'vscode' import { cfg, gstate, journeys, notes, showError, store } from '../app' import { refreshAll } from '../refresh' import { treeView } from '../sidebar/notesTree' -import { folderProblem } from '../noteModel' -import { DEFAULT_FOLDER, folderName } from '../store' -import { plural } from '../text' -import { wfs } from '../workspaceFs' +import { folderProblem } from '../core/format/noteModel' +import { DEFAULT_FOLDER, folderName } from './store' +import { plural } from '../core/text' +import { wfs } from '../platform/workspaceFs' /** The notes folder as last set (a change offers to move the notes). */ let currentFolder = DEFAULT_FOLDER diff --git a/src/identity.ts b/src/notes/identity.ts similarity index 94% rename from src/identity.ts rename to src/notes/identity.ts index 4a0c80a..75adee0 100644 --- a/src/identity.ts +++ b/src/notes/identity.ts @@ -3,9 +3,9 @@ import * as vscode from 'vscode' import * as os from 'os' -import { cfg, state } from './app' -import { git } from './checkout' -import { Message, NoteEvent } from './noteModel' +import { cfg, state } from '../app' +import { git } from '../platform/checkout' +import { Message, NoteEvent } from '../core/format/noteModel' import { Note } from './store' let gitName: string | undefined diff --git a/src/notes/location.ts b/src/notes/location.ts index 154835b..188f414 100644 --- a/src/notes/location.ts +++ b/src/notes/location.ts @@ -2,14 +2,14 @@ // the small helpers about workspace paths and a document's lines that go with that. import * as vscode from 'vscode' -import { anchor, Loc } from '../anchor' +import { anchor, Loc } from '../core/anchors/anchor' import { log, notes, store } from '../app' -import { commitInfo, otherBranch } from '../checkout' +import { commitInfo, otherBranch } from '../platform/checkout' import { refreshAll } from '../refresh' -import { captureAnchor, NoteData } from '../noteModel' -import { folderName, Note } from '../store' -import { diskLines, docLines } from '../documents' -import { wfs } from '../workspaceFs' +import { captureAnchor, NoteData } from '../core/format/noteModel' +import { folderName, Note } from './store' +import { diskLines, docLines } from '../platform/documents' +import { wfs } from '../platform/workspaceFs' import { folderPage } from './pages' type Anchor = NoteData['anchor'] diff --git a/src/notes/move.ts b/src/notes/move.ts index f3bf18d..4cc27f8 100644 --- a/src/notes/move.ts +++ b/src/notes/move.ts @@ -3,10 +3,10 @@ import * as vscode from 'vscode' import { byId, setCtx, store } from '../app' import { refreshAll } from '../refresh' -import { Note } from '../store' -import { noteTitle, rangeLabel } from '../text' +import { Note } from './store' +import { noteTitle, rangeLabel } from '../core/text' import { anchorAt, docUri, markPlaced, missing, pastEnd, reanchorAll, relPath, saveIfClean, selectedLines, toLoc, withinLines } from './location' -import { docLines } from '../documents' +import { docLines } from '../platform/documents' import { partialSelection } from './create' import { offerUndo, snapshot } from './undo' import { notesFrom } from './which' diff --git a/src/notes/pages.ts b/src/notes/pages.ts index 448ad5a..5d463c9 100644 --- a/src/notes/pages.ts +++ b/src/notes/pages.ts @@ -3,10 +3,10 @@ import * as vscode from 'vscode' import { byId } from '../app' -import { Note } from '../store' -import { plain, rangeLabel } from '../text' -import { wfs } from '../workspaceFs' -import { baseName } from '../paths' +import { Note } from './store' +import { plain, rangeLabel } from '../core/text' +import { wfs } from '../platform/workspaceFs' +import { baseName } from '../core/paths' /** A folder note's thread lives on a read-only page about the folder (there is no document to put it on). */ const FOLDER_SCHEME = 'code-notes-folder' diff --git a/src/notes/prompt.ts b/src/notes/prompt.ts index cc28f09..0281386 100644 --- a/src/notes/prompt.ts +++ b/src/notes/prompt.ts @@ -3,12 +3,12 @@ import * as vscode from 'vscode' import { byId, log, notes } from '../app' -import { me, waitingForAgent } from '../identity' +import { me, waitingForAgent } from './identity' import { checked } from '../sidebar/notesFilter' -import { folderName, Note } from '../store' -import { plural, rangeLabel } from '../text' +import { folderName, Note } from './store' +import { plural, rangeLabel } from '../core/text' import { notesFrom } from './which' -import { fileName } from '../jsonFolder' +import { fileName } from '../platform/jsonFolder' /** The prompt's words; `dir`: the notes folder. No frozen timestamp: a prompt pasted an hour later must not date replies in the past. */ const PROMPT = { diff --git a/src/notes/reply.ts b/src/notes/reply.ts index 13e79ad..23ccef0 100644 --- a/src/notes/reply.ts +++ b/src/notes/reply.ts @@ -5,11 +5,11 @@ import * as vscode from 'vscode' import { log, now, store } from '../app' import { askClaude } from '../ask/run' import { askAlways } from '../ask/settings' -import { me } from '../identity' +import { me } from './identity' import { refreshAll } from '../refresh' -import { markRead } from '../seen' -import { Note } from '../store' -import { noteTitle } from '../text' +import { markRead } from './seen' +import { Note } from './store' +import { noteTitle } from '../core/text' import { noteOfThread, revealed, syncThread } from '../threads/sync' import { shape, shapeOf } from './changedOnDisk' import { addEvent, setStatus, statusEvent, undoResolveEvent } from './status' diff --git a/src/notes/reveal.ts b/src/notes/reveal.ts index 2f084c7..6912875 100644 --- a/src/notes/reveal.ts +++ b/src/notes/reveal.ts @@ -3,19 +3,19 @@ import * as vscode from 'vscode' import { byId, log, mapPanel, showError } from '../app' -import { ownSelection } from '../claudeChatLinks' -import { markRead, visitFrom } from '../seen' +import { ownSelection } from '../codeLinks/claudeChatLinks' +import { markRead, visitFrom } from './seen' import { journeyOfNote } from '../sidebar/journeyRows' import { Node, noteNode } from '../sidebar/nodes' import { matchesFilter } from '../sidebar/notesFilter' import { tree, treeView } from '../sidebar/notesTree' -import { Note } from '../store' +import { Note } from './store' import { threadRange } from '../threads/comments' import { editorSettling, editorShownAt, setCollapse, settling } from '../threads/settle' import { expandWhenMade, revealed, syncThread, threads } from '../threads/sync' import { openRef } from '../tour/refs' import { walk } from '../tour/instances' -import { wfs } from '../workspaceFs' +import { wfs } from '../platform/workspaceFs' import { rangesAskedAt, waitUntil } from './commentRanges' import { clampLines, docUri, missing, notesFor } from './location' import { startMove } from './move' diff --git a/src/seen.ts b/src/notes/seen.ts similarity index 97% rename from src/seen.ts rename to src/notes/seen.ts index a2137d2..2a21181 100644 --- a/src/seen.ts +++ b/src/notes/seen.ts @@ -1,10 +1,10 @@ // What the person has read: per note, how many of its messages and status changes they have seen; per journey, whether // it was there when they last looked. Kept in the workspace state, out of the shared note and journey files. -import { journeys, notes, state } from './app' +import { journeys, notes, state } from '../app' import { evMine, mine } from './identity' -import { LoadedJourney, posKey } from './journeys/steps' -import { refreshAll } from './refresh' +import { LoadedJourney, posKey } from '../journeys/steps' +import { refreshAll } from '../refresh' import { Note } from './store' const SEEN_KEY = 'codeNotes.seenCount' // note id -> how many of its messages the person has seen diff --git a/src/notes/sessions.ts b/src/notes/sessions.ts index 3af91d4..3eec76a 100644 --- a/src/notes/sessions.ts +++ b/src/notes/sessions.ts @@ -5,7 +5,7 @@ import { notes, state } from '../app' import { refreshAll } from '../refresh' import { Node, sessionOf } from '../sidebar/nodes' import { HIDDEN_KEY, hiddenSessions, setSessionHidden } from '../sidebar/notesFilter' -import { folderName } from '../store' +import { folderName } from './store' import { resolve, trash } from './status' /** The session a command is about: its row's, the only one, or the one picked ('' is the notes without a session). */ diff --git a/src/notes/status.ts b/src/notes/status.ts index bb6f760..15c33ca 100644 --- a/src/notes/status.ts +++ b/src/notes/status.ts @@ -2,14 +2,14 @@ import * as vscode from 'vscode' import { byId, notes, now, store } from '../app' -import { evMine, me } from '../identity' +import { evMine, me } from './identity' import { refreshAll } from '../refresh' -import { markRead, seenCount, setSeen, unread } from '../seen' +import { markRead, seenCount, setSeen, unread } from './seen' import { checked, matchesFilter } from '../sidebar/notesFilter' import { treeView } from '../sidebar/notesTree' -import { NoteEvent } from '../noteModel' -import { folderName, Note } from '../store' -import { describeNotes, noteTitle, plural } from '../text' +import { NoteEvent } from '../core/format/noteModel' +import { folderName, Note } from './store' +import { describeNotes, noteTitle, plural } from '../core/text' import { revealed } from '../threads/sync' import { shape, shapeOf } from './changedOnDisk' import { offerUndo, snapshot } from './undo' diff --git a/src/store.ts b/src/notes/store.ts similarity index 98% rename from src/store.ts rename to src/notes/store.ts index f536c73..73f3563 100644 --- a/src/store.ts +++ b/src/notes/store.ts @@ -1,11 +1,11 @@ import * as vscode from 'vscode' -import { wfs } from './workspaceFs' +import { wfs } from '../platform/workspaceFs' import * as fs from 'fs' import * as path from 'path' -import { placeFile, settingFolder } from './paths' -import { fileName, jsonFilesIn, jsonName, readText, watchJsonFiles } from './jsonFolder' -import { NoteData, agentReadme, folderProblem, merge, parseNote, serialize, titleOf } from './noteModel' -import { SaveFailures } from './saveFailures' +import { placeFile, settingFolder } from '../core/paths' +import { fileName, jsonFilesIn, jsonName, readText, watchJsonFiles } from '../platform/jsonFolder' +import { NoteData, agentReadme, folderProblem, merge, parseNote, serialize, titleOf } from '../core/format/noteModel' +import { SaveFailures } from '../platform/saveFailures' // One JSON file per note in //.json. One file per note so an agent and // the extension never overwrite each other's notes. A note IS its file: the file name is its identity (an "id" diff --git a/src/notes/suggestion.ts b/src/notes/suggestion.ts index 200f7e6..c08ce01 100644 --- a/src/notes/suggestion.ts +++ b/src/notes/suggestion.ts @@ -4,9 +4,9 @@ import * as vscode from 'vscode' import { byId, showError, understanding } from '../app' import { refreshAll } from '../refresh' import { anchorAt, docUri, missing, noAnchor, otherAnchor, pastEnd } from './location' -import { rangeLabel } from '../text' +import { rangeLabel } from '../core/text' import { suggestionOf } from '../threads/comments' -import { docLines } from '../documents' +import { docLines } from '../platform/documents' /** Apply on an agent's ```suggestion block: replaces the note's lines; the editor's Undo takes it back. */ export async function applySuggestion(id: string, mi: number, k: number): Promise { diff --git a/src/notes/undo.ts b/src/notes/undo.ts index 4c0925d..f159aa7 100644 --- a/src/notes/undo.ts +++ b/src/notes/undo.ts @@ -3,8 +3,8 @@ import * as vscode from 'vscode' import { setCtx } from '../app' -import { NoteData } from '../noteModel' -import { Note } from '../store' +import { NoteData } from '../core/format/noteModel' +import { Note } from './store' /** The last undoable action: the toast's Undo, and "Code Notes: Undo" after the toast is gone. */ let lastUndo: { what: string; run: () => Promise } | undefined diff --git a/src/notes/unread.ts b/src/notes/unread.ts index 06ac27e..dd6eeb7 100644 --- a/src/notes/unread.ts +++ b/src/notes/unread.ts @@ -2,12 +2,12 @@ import * as vscode from 'vscode' import { firstFolder, mapPanel, notes } from '../app' -import { mine } from '../identity' -import { markRead, restoreSeen, seenSnapshot, setSeen, unread, visitFrom } from '../seen' +import { mine } from './identity' +import { markRead, restoreSeen, seenSnapshot, setSeen, unread, visitFrom } from './seen' import { order, sessionOf } from '../sidebar/nodes' import { hiddenSessions } from '../sidebar/notesFilter' -import { Note } from '../store' -import { plural } from '../text' +import { Note } from './store' +import { plural } from '../core/text' import { revealed } from '../threads/sync' import { refreshAll } from '../refresh' import { notesFor, relPath } from './location' diff --git a/src/notes/which.ts b/src/notes/which.ts index 0293e94..70329b2 100644 --- a/src/notes/which.ts +++ b/src/notes/which.ts @@ -3,8 +3,8 @@ import * as vscode from 'vscode' import { byId } from '../app' import { Node, order } from '../sidebar/nodes' -import { Note } from '../store' -import { noteTitle, rangeLabel } from '../text' +import { Note } from './store' +import { noteTitle, rangeLabel } from '../core/text' import { notesAtLine } from './location' import { noteOfThread, revealed } from '../threads/sync' diff --git a/src/claude.ts b/src/platform/agent/claude.ts similarity index 100% rename from src/claude.ts rename to src/platform/agent/claude.ts diff --git a/src/claudeCli.ts b/src/platform/agent/claudeCli.ts similarity index 100% rename from src/claudeCli.ts rename to src/platform/agent/claudeCli.ts diff --git a/src/checkout.ts b/src/platform/checkout.ts similarity index 97% rename from src/checkout.ts rename to src/platform/checkout.ts index d004500..084c7bb 100644 --- a/src/checkout.ts +++ b/src/platform/checkout.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode' import { gitOut } from './git' -import { Note } from './store' +import { Note } from '../notes/store' /** Identity and branch reads are quick: a git that hangs longer than this is given up. */ const QUICK_GIT_TIMEOUT_MS = 3000 diff --git a/src/decorations.ts b/src/platform/decorations.ts similarity index 100% rename from src/decorations.ts rename to src/platform/decorations.ts diff --git a/src/devReload.ts b/src/platform/devReload.ts similarity index 100% rename from src/devReload.ts rename to src/platform/devReload.ts diff --git a/src/documents.ts b/src/platform/documents.ts similarity index 100% rename from src/documents.ts rename to src/platform/documents.ts diff --git a/src/followEdits.ts b/src/platform/followEdits.ts similarity index 98% rename from src/followEdits.ts rename to src/platform/followEdits.ts index 82aa977..53dea24 100644 --- a/src/followEdits.ts +++ b/src/platform/followEdits.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import { LineEdit, followLine, shiftLine } from './lineFollow' +import { LineEdit, followLine, shiftLine } from '../core/anchors/lineFollow' import { docLines } from './documents' // Lines remembered by text (a beat's line, a code link's lines, value hints) follow edits to their file in two moves: diff --git a/src/git.ts b/src/platform/git.ts similarity index 100% rename from src/git.ts rename to src/platform/git.ts diff --git a/src/gitRenames.ts b/src/platform/gitRenames.ts similarity index 100% rename from src/gitRenames.ts rename to src/platform/gitRenames.ts diff --git a/src/jsonFolder.ts b/src/platform/jsonFolder.ts similarity index 98% rename from src/jsonFolder.ts rename to src/platform/jsonFolder.ts index b1212b2..7440179 100644 --- a/src/jsonFolder.ts +++ b/src/platform/jsonFolder.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import { wfs } from './workspaceFs' -import { baseName } from './paths' +import { baseName } from '../core/paths' // Folders of JSON files the extension reads one file per item from (notes, journeys): watched for changes, read once // at load, and what a file's name says. diff --git a/src/memento.ts b/src/platform/memento.ts similarity index 100% rename from src/memento.ts rename to src/platform/memento.ts diff --git a/src/quickPick.ts b/src/platform/quickPick.ts similarity index 100% rename from src/quickPick.ts rename to src/platform/quickPick.ts diff --git a/src/saveFailures.ts b/src/platform/saveFailures.ts similarity index 100% rename from src/saveFailures.ts rename to src/platform/saveFailures.ts diff --git a/src/symbolBlocks.ts b/src/platform/symbolBlocks.ts similarity index 99% rename from src/symbolBlocks.ts rename to src/platform/symbolBlocks.ts index 4d9854e..3e9993b 100644 --- a/src/symbolBlocks.ts +++ b/src/platform/symbolBlocks.ts @@ -2,7 +2,7 @@ // part), cached per document version. Used by the code lenses and the Journeys view's "In this file" ranking. import * as vscode from 'vscode' -import { Block, blocksFromSymbols, blocksFromText, Sym } from './codeBlocks' +import { Block, blocksFromSymbols, blocksFromText, Sym } from '../core/codeBlocks' import { docLines } from './documents' /** The blocks per document. Symbols not ready yet (a language server still starting) are not kept for long: the diff --git a/src/workspaceFs.ts b/src/platform/workspaceFs.ts similarity index 100% rename from src/workspaceFs.ts rename to src/platform/workspaceFs.ts diff --git a/src/podcast/listenView.ts b/src/podcast/listenView.ts index df97e9a..10b195b 100644 --- a/src/podcast/listenView.ts +++ b/src/podcast/listenView.ts @@ -11,7 +11,7 @@ import * as vscode from 'vscode' import { webviewPage } from '../webview/page' import { journeysFolderName } from '../journeys/journeys' -import { folderName } from '../store' +import { folderName } from '../notes/store' import { setCtx } from '../app' export const LISTEN_VIEW = 'codeNotes.listen' diff --git a/src/podcast/load.ts b/src/podcast/load.ts index c072d2a..b80f1fb 100644 --- a/src/podcast/load.ts +++ b/src/podcast/load.ts @@ -7,10 +7,10 @@ import * as vscode from 'vscode' import { journeys, log } from '../app' import { stepFileUri } from '../journeys/codeGroup' -import { git } from '../checkout' +import { git } from '../platform/checkout' import { fileOf, LoadedJourney } from '../journeys/steps' -import { readText } from '../jsonFolder' -import { wfs } from '../workspaceFs' +import { readText } from '../platform/jsonFolder' +import { wfs } from '../platform/workspaceFs' import { isPodcastFile, podcastFileOf, PodcastProblem } from './model' import { audioPathProblem, lineCol, locate, markFileNames, validatePodcast, Validation } from './validate' diff --git a/src/podcast/player.ts b/src/podcast/player.ts index dec9ff3..785e302 100644 --- a/src/podcast/player.ts +++ b/src/podcast/player.ts @@ -31,7 +31,7 @@ import { calmViews, clock, Episode, LatestWins, markTimes, planMarks, podcastFil import { MarkLights, PlannedMark } from './marks' import { Camera, CUE_LEAD_S, cueText } from './camera' import { showInCodeGroup, stepFileUri } from '../journeys/codeGroup' -import { baseName } from '../paths' +import { baseName } from '../core/paths' import { podcastReports, PodcastRead, readPodcast, strayPodcasts } from './load' import { afterStep, remapTime, resumeTime } from './resume' import { brokenLinks, playNotice } from './validate' diff --git a/src/refresh.ts b/src/refresh.ts index c938d04..e54082c 100644 --- a/src/refresh.ts +++ b/src/refresh.ts @@ -5,11 +5,11 @@ import { journeys, notes, setCtx, store, understanding } from './app' import { refreshAskStatus } from './ask/run' import { refreshDecorations } from './notes/decorations' import { notesAtLine } from './notes/location' -import { unread } from './seen' +import { unread } from './notes/seen' import { sessionOf } from './sidebar/nodes' import { checked, filter, FILTERS, groupMode, hiddenSessions, matchesFilter } from './sidebar/notesFilter' import { tree, treeView } from './sidebar/notesTree' -import { plural } from './text' +import { plural } from './core/text' import { syncThreads } from './threads/sync' import { walk } from './tour/instances' diff --git a/src/sidebar/journeyRows.ts b/src/sidebar/journeyRows.ts index 6c1a2cb..ff2a9ae 100644 --- a/src/sidebar/journeyRows.ts +++ b/src/sidebar/journeyRows.ts @@ -3,12 +3,12 @@ import * as vscode from 'vscode' import { gstate, journeys, notes } from '../app' -import { mine } from '../identity' -import { ListModel } from '../journeyList' +import { mine } from '../notes/identity' +import { ListModel } from '../core/list/journeyList' import { LoadedJourney } from '../journeys/steps' -import { isNewJourney, unread } from '../seen' -import { Note } from '../store' -import { isolate, plural } from '../text' +import { isNewJourney, unread } from '../notes/seen' +import { Note } from '../notes/store' +import { isolate, plural } from '../core/text' import { isUpdateRequest } from '../tour/askStep' import { provenance } from '../tour/provenance' import { tourState, walk } from '../tour/instances' @@ -17,7 +17,7 @@ import { journeysTree, journeysView } from './journeysTree' import { activeRel, listModel, listState, staleCount, staleLine } from './listModel' import { badJourneyNodes, cached, jgroupNode, journeyNode, journeyRowNode, Node, noteNode, order } from './nodes' import { matchesFilter } from './notesFilter' -import { fileName } from '../jsonFolder' +import { fileName } from '../platform/jsonFolder' import { podcasts } from '../podcast/player' import { clock } from '../podcast/model' diff --git a/src/sidebar/journeysTree.ts b/src/sidebar/journeysTree.ts index c96f56c..f834002 100644 --- a/src/sidebar/journeysTree.ts +++ b/src/sidebar/journeysTree.ts @@ -3,8 +3,8 @@ import * as vscode from 'vscode' import { journeys, mapPanel, state } from '../app' -import { Group, SORTS } from '../journeyList' -import { pickOne } from '../quickPick' +import { Group, SORTS } from '../core/list/journeyList' +import { pickOne } from '../platform/quickPick' import { walkJourney } from '../tour/commands' import { badJourneyNodes, jgroupNode, jmoreNode, journeyRowNode, Node } from './nodes' import { journeyQuestionRows, questionRows, revealHereGroup } from './journeyRows' diff --git a/src/sidebar/listModel.ts b/src/sidebar/listModel.ts index 3d448da..aed251a 100644 --- a/src/sidebar/listModel.ts +++ b/src/sidebar/listModel.ts @@ -3,11 +3,11 @@ import * as vscode from 'vscode' import { journeys, state } from '../app' -import { blockAt } from '../codeBlocks' -import { blocksOf } from '../symbolBlocks' -import { buildList, ListItem, ListKind, ListModel, Sort } from '../journeyList' +import { blockAt } from '../core/codeBlocks' +import { blocksOf } from '../platform/symbolBlocks' +import { buildList, ListItem, ListKind, ListModel, Sort } from '../core/list/journeyList' import { LoadedJourney, posKey } from '../journeys/steps' -import { isNewJourney } from '../seen' +import { isNewJourney } from '../notes/seen' import { relPath } from '../notes/location' import { tourState, walk } from '../tour/instances' import { refreshing } from '../write/refreshJourney' diff --git a/src/sidebar/nodes.ts b/src/sidebar/nodes.ts index cd9c003..6c198b3 100644 --- a/src/sidebar/nodes.ts +++ b/src/sidebar/nodes.ts @@ -3,10 +3,10 @@ import * as vscode from 'vscode' import { journeys, notes } from '../app' -import { Group } from '../journeyList' +import { Group } from '../core/list/journeyList' import { LoadedJourney } from '../journeys/steps' -import { Severity } from '../noteModel' -import { Note } from '../store' +import { Severity } from '../core/format/noteModel' +import { Note } from '../notes/store' import { matchesFilter } from './notesFilter' export type Node = diff --git a/src/sidebar/notesFilter.ts b/src/sidebar/notesFilter.ts index fc03748..3758873 100644 --- a/src/sidebar/notesFilter.ts +++ b/src/sidebar/notesFilter.ts @@ -4,8 +4,8 @@ import * as vscode from 'vscode' import { byId, notes, setCtx, state, understanding } from '../app' import { refreshAll } from '../refresh' -import { unread } from '../seen' -import { Note } from '../store' +import { unread } from '../notes/seen' +import { Note } from '../notes/store' import { setCollapse } from '../threads/settle' import { revealed, threads } from '../threads/sync' import { journeyOfNote } from './journeyRows' diff --git a/src/sidebar/notesTree.ts b/src/sidebar/notesTree.ts index edcf500..f4a61cb 100644 --- a/src/sidebar/notesTree.ts +++ b/src/sidebar/notesTree.ts @@ -2,8 +2,8 @@ import * as vscode from 'vscode' import { notes, setCtx, store } from '../app' -import { unread } from '../seen' -import { Note } from '../store' +import { unread } from '../notes/seen' +import { Note } from '../notes/store' import { journeyOfNote, journeyQuestionRows, journeyRows, questionRows } from './journeyRows' import { journeysTree } from './journeysTree' import { fileNode, Node, noteNode, rowOrder, sessionNode, sessionOf } from './nodes' diff --git a/src/sidebar/rowItems.ts b/src/sidebar/rowItems.ts index eb666a2..8946e58 100644 --- a/src/sidebar/rowItems.ts +++ b/src/sidebar/rowItems.ts @@ -4,17 +4,17 @@ import * as vscode from 'vscode' import { notes, store } from '../app' import { askErrors, asking } from '../ask/run' -import { mine } from '../identity' -import { unread } from '../seen' -import { Note } from '../store' -import { ago, isolate, plain, plural, rangeLabel } from '../text' +import { mine } from '../notes/identity' +import { unread } from '../notes/seen' +import { Note } from '../notes/store' +import { ago, isolate, plain, plural, rangeLabel } from '../core/text' import { missing } from '../notes/location' import { tourState, walk } from '../tour/instances' import { badJourneyItem, journeyItem, journeyOfNote, questionsItem, showIntro, stepLinkOf } from './journeyRows' import { listState } from './listModel' import { lastMessage, Node, sessionOf, SEV_ICON } from './nodes' import { hiddenSessions, ownRow } from './notesFilter' -import { baseName } from '../paths' +import { baseName } from '../core/paths' /** The row of each kind of node. */ const ITEMS: { [K in Node['kind']]: (node: Extract) => vscode.TreeItem } = { diff --git a/src/testApi.ts b/src/testApi.ts index edea227..be80c39 100644 --- a/src/testApi.ts +++ b/src/testApi.ts @@ -4,10 +4,10 @@ import * as vscode from 'vscode' import { beats, claudeLinks, codeLinks, gstate, journeys, KEY, mapPanel, notes, state, store, tourItems, tutorialSpot, understanding, valueHints } from './app' import { askErrors, asking } from './ask/run' -import { me } from './identity' -import { Note } from './store' +import { me } from './notes/identity' +import { Note } from './notes/store' import { applySuggestion } from './notes/suggestion' -import { unread } from './seen' +import { unread } from './notes/seen' import { journeysTree } from './sidebar/journeysTree' import { journeyItem } from './sidebar/journeyRows' import { listModel } from './sidebar/listModel' diff --git a/src/threads/comments.ts b/src/threads/comments.ts index 06463eb..313ae13 100644 --- a/src/threads/comments.ts +++ b/src/threads/comments.ts @@ -3,26 +3,26 @@ import * as vscode from 'vscode' import * as os from 'os' -import { lineDiff } from '../staleDiff' -import { linkify } from '../linkifyAnswer' +import { lineDiff } from '../core/anchors/staleDiff' +import { linkify } from '../core/linkifyAnswer' import { alsoAllow, BANNER_COMMANDS, byId, cmdLink, MESSAGE_COMMANDS, systemMarkdown, titledCmdLink, trustedMarkdown, understanding } from '../app' import { askErrors, asking } from '../ask/run' import type { ThreadStatus } from '../check/controller' -import { codeLinkMarkup, linkPhrases, PH, PH_RE } from '../codeLinkText' -import { otherBranch } from '../checkout' -import { isAgent, mine } from '../identity' +import { codeLinkMarkup, linkPhrases, PH, PH_RE } from '../core/codeLinkText' +import { otherBranch } from '../platform/checkout' +import { isAgent, mine } from '../notes/identity' import { escapeTags } from '../journeys/textFormat' -import { seenCount, visitFrom } from '../seen' +import { seenCount, visitFrom } from '../notes/seen' import { journeyOfNote, stepLinkOf } from '../sidebar/journeyRows' -import { NoteEvent } from '../noteModel' -import { Note } from '../store' -import { plural, rangeLabel } from '../text' +import { NoteEvent } from '../core/format/noteModel' +import { Note } from '../notes/store' +import { plural, rangeLabel } from '../core/text' import { questionDone } from '../check/types' import { seeAlsoLink } from '../tour/checkTour' import { tourState, walk } from '../tour/instances' import { docUri, missing, openDoc, pastEnd } from '../notes/location' import { syncThread } from './sync' -import { docLines } from '../documents' +import { docLines } from '../platform/documents' export function threadRange(n: Note): vscode.Range { return new vscode.Range(n.data.range.start - 1, 0, n.data.range.end - 1, 0) diff --git a/src/threads/sync.ts b/src/threads/sync.ts index 8413595..740bc3c 100644 --- a/src/threads/sync.ts +++ b/src/threads/sync.ts @@ -3,13 +3,13 @@ import * as vscode from 'vscode' import { byId, cfg, controller, notes, understanding } from '../app' import { askErrors, asking } from '../ask/run' -import { otherBranch } from '../checkout' +import { otherBranch } from '../platform/checkout' import { docUri, missing, openDoc, pastEnd } from '../notes/location' -import { seenCount, unread, visitFrom } from '../seen' +import { seenCount, unread, visitFrom } from '../notes/seen' import { stepLinkOf } from '../sidebar/journeyRows' import { hiddenInEditor } from '../sidebar/notesFilter' -import { Note } from '../store' -import { labelSafe, shortQ } from '../text' +import { Note } from '../notes/store' +import { labelSafe, shortQ } from '../core/text' import { tourState, walk } from '../tour/instances' import { commentsOf, expanded, threadRange } from './comments' import { afterEditorSettles, newThread, setThread, settling, whenSettled } from './settle' diff --git a/src/tour/askStep.ts b/src/tour/askStep.ts index f2d2006..78e264e 100644 --- a/src/tour/askStep.ts +++ b/src/tour/askStep.ts @@ -8,7 +8,7 @@ import { fileOf, LoadedJourney } from '../journeys/steps' import { createNote } from '../notes/create' import { reveal } from '../notes/reveal' import { refreshAll } from '../refresh' -import { Note } from '../store' +import { Note } from '../notes/store' import { card, tourState, walk } from './instances' import { podcasts } from '../podcast/player' diff --git a/src/tour/card.ts b/src/tour/card.ts index aacea7e..4892d4a 100644 --- a/src/tour/card.ts +++ b/src/tour/card.ts @@ -2,17 +2,17 @@ // has no code to sit on; the bar on the step's lines and the ref opened from the card. import * as vscode from 'vscode' import { beats, cmdLink, codeLinks, journeys, KEY, mapPanel, titledCmdLink, valueHints } from '../app' -import { codeLinkMarkup, linkPhrases, PH, PH_RE } from '../codeLinkText' -import { setDecorations } from '../decorations' -import { readLinks, readValues } from '../journeyModel' +import { codeLinkMarkup, linkPhrases, PH, PH_RE } from '../core/codeLinkText' +import { setDecorations } from '../platform/decorations' +import { readLinks, readValues } from '../core/format/journeyModel' import { escapeTags } from '../journeys/textFormat' import { fileOf, LoadedJourney } from '../journeys/steps' import { Asked, askedOf, askedText } from '../sidebar/journeyRows' import { refreshDecorations as refreshNoteDecorations } from '../notes/decorations' import { linesOfUri } from '../notes/location' import { MarkPainter } from '../marks/lights' -import { blocksOf } from '../symbolBlocks' -import { labelSafe } from '../text' +import { blocksOf } from '../platform/symbolBlocks' +import { labelSafe } from '../core/text' import { afterEditorSettles, newThread, setThread, settling, whenSettled } from '../threads/settle' import { nextStop, seeAlsoLink } from './checkTour' import { TourState } from './state' diff --git a/src/tour/checkTour.ts b/src/tour/checkTour.ts index 9a8d5bb..862a91a 100644 --- a/src/tour/checkTour.ts +++ b/src/tour/checkTour.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode' import { cmdLink, journeys, mapPanel, understanding } from '../app' import { Check, questionDone } from '../check/types' -import { seeAlso } from '../journeyList' +import { seeAlso } from '../core/list/journeyList' import { LoadedJourney } from '../journeys/steps' import { listItems } from '../sidebar/listModel' import { endJourney } from './commands' diff --git a/src/tour/commands.ts b/src/tour/commands.ts index e6534f0..67862ca 100644 --- a/src/tour/commands.ts +++ b/src/tour/commands.ts @@ -6,7 +6,7 @@ import { beats, codeLinks, gstate, journeys, log, mapPanel, state, valueHints } import { prefixUsed } from '../chords' import { MAP_VIEW } from '../journeys/mapPanel' import { fileOf, journeyById, LoadedJourney, posKey } from '../journeys/steps' -import { markJourneysSeen } from '../seen' +import { markJourneysSeen } from '../notes/seen' import { INTRO_KEY, showIntro } from '../sidebar/journeyRows' import { tree } from '../sidebar/notesTree' import { cardOnly, codeGetsMoreRoom, keepWidthOnFocus, noteLayout, panelFits, roomForMap } from './panelLayout' diff --git a/src/tour/lenses.ts b/src/tour/lenses.ts index 723b7ee..f3e5de1 100644 --- a/src/tour/lenses.ts +++ b/src/tour/lenses.ts @@ -3,9 +3,9 @@ import * as vscode from 'vscode' import { cfg, journeys, understanding } from '../app' -import { Block, blockAt, groupSteps } from '../codeBlocks' +import { Block, blockAt, groupSteps } from '../core/codeBlocks' import { fileOf } from '../journeys/steps' -import { blocksOf } from '../symbolBlocks' +import { blocksOf } from '../platform/symbolBlocks' import { inNotesFolder, notesFor, relPath } from '../notes/location' import { card, tourState, walk } from './instances' diff --git a/src/tour/mapMessages.ts b/src/tour/mapMessages.ts index e017003..0361f07 100644 --- a/src/tour/mapMessages.ts +++ b/src/tour/mapMessages.ts @@ -3,8 +3,8 @@ import * as vscode from 'vscode' import { beats, byId, cfg, gstate, journeys, KEY, log, mapPanel, state, understanding } from '../app' -import { git } from '../checkout' -import { ageOf } from '../journeyList' +import { git } from '../platform/checkout' +import { ageOf } from '../core/list/journeyList' import { LEGEND_HIDDEN_KEY, MapMessage, TourInfo } from '../journeys/mapPanel' import { fileOf, LoadedJourney } from '../journeys/steps' import { reveal } from '../notes/reveal' @@ -12,7 +12,7 @@ import { askedOf } from '../sidebar/journeyRows' import { journeysTree } from '../sidebar/journeysTree' import { listModel, listState, SORT_KEY } from '../sidebar/listModel' import { relPath } from '../notes/location' -import { wfs } from '../workspaceFs' +import { wfs } from '../platform/workspaceFs' import { refreshJourney } from '../write/refreshJourney' import { askStep, askUpdate } from './askStep' import { openCheckpoint } from './checkTour' diff --git a/src/tour/panelLayout.ts b/src/tour/panelLayout.ts index f3521df..2faea06 100644 --- a/src/tour/panelLayout.ts +++ b/src/tour/panelLayout.ts @@ -4,7 +4,7 @@ import * as vscode from 'vscode' import { gstate, KEY, log, mapPanel } from '../app' import { MAP_VIEW } from '../journeys/mapPanel' -import { listeningShare, panelShare } from '../panelWidth' +import { listeningShare, panelShare } from '../core/panelWidth' import { walk } from './instances' /** The panel's width as the reader left it (a share of the editor area), every journey. */ diff --git a/src/tour/pick.ts b/src/tour/pick.ts index 3ffd997..646990d 100644 --- a/src/tour/pick.ts +++ b/src/tour/pick.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode' import { journeys } from '../app' import { LoadedJourney, posKey } from '../journeys/steps' -import { pickOne } from '../quickPick' +import { pickOne } from '../platform/quickPick' import { Node } from '../sidebar/nodes' import { writeJourney } from '../write/writeJourney' import { journeyModel, modelLabel } from '../write/claudeRun' diff --git a/src/tour/refs.ts b/src/tour/refs.ts index 12ff07f..c8a40e8 100644 --- a/src/tour/refs.ts +++ b/src/tour/refs.ts @@ -3,10 +3,10 @@ import * as vscode from 'vscode' import { showError } from '../app' -import { setDecorations } from '../decorations' +import { setDecorations } from '../platform/decorations' import { fileOf, LoadedJourney } from '../journeys/steps' import { clampLines } from '../notes/location' -import { wfs } from '../workspaceFs' +import { wfs } from '../platform/workspaceFs' import { cardLine } from './stepPlace' import { card, tourState, walk } from './instances' diff --git a/src/tour/stepText.ts b/src/tour/stepText.ts index dcb9ec4..83efaef 100644 --- a/src/tour/stepText.ts +++ b/src/tour/stepText.ts @@ -5,10 +5,10 @@ // where it is now (`relocate`), drop the refs already on screen (`onScreen`), and say each as a link or a struck-out // name (`label`). `stepText` composes them. import { fileOf, LoadedJourney } from '../journeys/steps' -import type { JStep } from '../journeyModel' -import { readLinks } from '../journeyModel' +import type { JStep } from '../core/format/journeyModel' +import { readLinks } from '../core/format/journeyModel' import { DIR, FILE_NAME, REF_IN_TEXT } from '../journeys/textFormat' -import { baseName } from '../paths' +import { baseName } from '../core/paths' /** A link in a step's text: where it goes now (renames, moved lines), and how it reads. */ export interface StepRef { label: string; file: string; line: number; end: number; gone: boolean; stale: boolean } diff --git a/src/tutorialSpot.ts b/src/tour/tutorialSpot.ts similarity index 97% rename from src/tutorialSpot.ts rename to src/tour/tutorialSpot.ts index 306b5e1..8fb7d49 100644 --- a/src/tutorialSpot.ts +++ b/src/tour/tutorialSpot.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import { setDecorations } from './decorations' +import { setDecorations } from '../platform/decorations' // The tutorial's card about the step card (the tutorial shows things in the editor too): while it is up, the // step's lines in the editor are boxed, so the eyes land on the card that sits right above them. An extension can't diff --git a/src/tour/walk.ts b/src/tour/walk.ts index c3b83ca..13ed121 100644 --- a/src/tour/walk.ts +++ b/src/tour/walk.ts @@ -2,14 +2,14 @@ // the status bar item, and where each journey was left. import * as vscode from 'vscode' import { beats, codeLinks, journeys, log, mapPanel, now, setCtx, state, tourItems } from '../app' -import { ownSelection } from '../claudeChatLinks' +import { ownSelection } from '../codeLinks/claudeChatLinks' import { fileOf, LoadedJourney, posKey } from '../journeys/steps' import { checkLinkNote } from '../check/wiring' import { revealJourneyRow } from '../sidebar/journeyRows' import { tree } from '../sidebar/notesTree' import { editorSettling } from '../threads/settle' import { refreshDecorations } from '../notes/decorations' -import { wfs } from '../workspaceFs' +import { wfs } from '../platform/workspaceFs' import type { StepCard } from './card' import { openCheckpoint, stopBy } from './checkTour' import { panelFits } from './panelLayout' @@ -18,7 +18,7 @@ import { pickJourney } from './pick' import { MAP_KEY, POS_KEY, ShownAt, TOUR_KEY, TourState } from './state' import { foldNotesOverlapping, syncStepNotes } from './stepNotes' import { cardLine, stepUri, wroteAt } from './stepPlace' -import { baseName } from '../paths' +import { baseName } from '../core/paths' import { stepFileUri } from '../journeys/codeGroup' type Pos = { step: number; id?: string; at: string } diff --git a/src/watch.ts b/src/watch.ts index 83677f3..713588c 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -2,15 +2,15 @@ // journey steps follow their code. import * as vscode from 'vscode' -import { Loc } from './anchor' -import { shift, swallows } from './lineFollow' +import { Loc } from './core/anchors/anchor' +import { shift, swallows } from './core/anchors/lineFollow' import { journeys, mapPanel, notes, store } from './app' -import { refreshBranch } from './checkout' -import { authorChanged } from './identity' +import { refreshBranch } from './platform/checkout' +import { authorChanged } from './notes/identity' import { fileOf } from './journeys/steps' import { applyIgnoreInGit, changeFolder, rewriteReadmes } from './notes/folder' import { refreshAll, updateCursorContext } from './refresh' -import { markRead, unread } from './seen' +import { markRead, unread } from './notes/seen' import { journeysTree } from './sidebar/journeysTree' import { findMovedFile, followMovedFiles, followRename, inNotesFolder, lineNotesFor, notesAtLine, notesFor, pathUri, reanchor, reanchorAll, recentCreates, relPath, toLoc } from './notes/location' import { noteVisibleEditors } from './threads/settle' @@ -18,8 +18,8 @@ import { refreshDecorations } from './notes/decorations' import { syncThread, threads } from './threads/sync' import { keepOffMap } from './tour/panelLayout' import { card, tourState, walk } from './tour/instances' -import { docLines } from './documents' -import { wfs } from './workspaceFs' +import { docLines } from './platform/documents' +import { wfs } from './platform/workspaceFs' /** Steps whose file was renamed or deleted on disk: follow the code into a file created just now, or go stale. */ async function followJourneyFiles(): Promise { diff --git a/src/write/claudeRun.ts b/src/write/claudeRun.ts index a7a0c85..845f183 100644 --- a/src/write/claudeRun.ts +++ b/src/write/claudeRun.ts @@ -8,9 +8,9 @@ import * as os from 'os' import * as path from 'path' import { cfg, extUri, showError } from '../app' import { claudeCli } from '../ask/settings' -import { Ask, AskOptions, AskResult, modelProblem } from '../claude' -import { folderName } from '../store' -import { clock, phaseOf } from '../writing' +import { Ask, AskOptions, AskResult, modelProblem } from '../platform/agent/claude' +import { folderName } from '../notes/store' +import { clock, phaseOf } from '../core/writing' import { Writing, writingChanged, writingNow } from './inProgress' /** The model a journey is written with (a request's `model`, the settings), and how it is named. */ diff --git a/src/write/inProgress.ts b/src/write/inProgress.ts index 76b6eb6..727dca9 100644 --- a/src/write/inProgress.ts +++ b/src/write/inProgress.ts @@ -1,8 +1,8 @@ // The journeys Claude is writing (or refreshing) now: never listed half-made; one row each while they are. import * as vscode from 'vscode' -import { Ask } from '../claude' -import { clock } from '../writing' +import { Ask } from '../platform/agent/claude' +import { clock } from '../core/writing' /** A journey being written: "Writing: · 1:20", its phase, the model, and the run (to cancel it). */ export interface Writing { id: string; question: string; started: number; phase: string; model: string; ask?: Ask } diff --git a/src/write/rank.ts b/src/write/rank.ts index 4155f7e..4068d54 100644 --- a/src/write/rank.ts +++ b/src/write/rank.ts @@ -3,9 +3,9 @@ import * as vscode from 'vscode' import { journeys } from '../app' import { LoadedJourney } from '../journeys/steps' -import { scoreJourney } from '../match' -import { pickOne } from '../quickPick' -import { shortQ } from '../text' +import { scoreJourney } from '../core/list/match' +import { pickOne } from '../platform/quickPick' +import { shortQ } from '../core/text' import { questionBesidesTitle } from '../tour/pick' import { journeyModel, modelLabel } from './claudeRun' diff --git a/src/write/refreshJourney.ts b/src/write/refreshJourney.ts index 8e24973..761bf10 100644 --- a/src/write/refreshJourney.ts +++ b/src/write/refreshJourney.ts @@ -6,14 +6,14 @@ import * as os from 'os' import * as path from 'path' import { journeys, log, mapPanel, showError } from '../app' import { claudeAllowed } from '../ask/trust' -import { AskResult } from '../claude' +import { AskResult } from '../platform/agent/claude' import { LoadedJourney } from '../journeys/steps' -import { pickOne } from '../quickPick' +import { pickOne } from '../platform/quickPick' import { journeysTree } from '../sidebar/journeysTree' import { staleCount, staleLine, staleSteps } from '../sidebar/listModel' -import { plural, shortQ } from '../text' +import { plural, shortQ } from '../core/text' import { walk } from '../tour/instances' -import { clock } from '../writing' +import { clock } from '../core/writing' import { bundledSkill, cliOrClipboard, journeyPy, modelLabel, runJourneySkill, skillAndModel, Staging, stagingFolder } from './claudeRun' import { startWriting, Writing } from './inProgress' diff --git a/src/write/requests.ts b/src/write/requests.ts index ae17e0a..667276a 100644 --- a/src/write/requests.ts +++ b/src/write/requests.ts @@ -3,13 +3,13 @@ import * as fs from 'fs' import * as path from 'path' import { claudeLinks, extVersion, journeys, log, mapPanel, showError, state } from '../app' import { claudeAllowed, trusted } from '../ask/trust' -import { modelProblem } from '../claude' -import { linkTarget } from '../linkUri' +import { modelProblem } from '../platform/agent/claude' +import { linkTarget } from '../core/linkUri' import { posKey } from '../journeys/steps' import { walkJourney } from '../tour/commands' import { walk } from '../tour/instances' import { MAP_KEY } from '../tour/state' -import { wfs } from '../workspaceFs' +import { wfs } from '../platform/workspaceFs' import { chooseJourney, confirmWrite, matchJourneys } from './rank' import { writeJourney } from './writeJourney' import { journeyModel, modelLabel } from './claudeRun' diff --git a/src/write/writeJourney.ts b/src/write/writeJourney.ts index 30f45bf..d021b79 100644 --- a/src/write/writeJourney.ts +++ b/src/write/writeJourney.ts @@ -7,14 +7,14 @@ import * as os from 'os' import * as path from 'path' import { journeys, log, showError } from '../app' import { claudeAllowed } from '../ask/trust' -import { AskResult } from '../claude' +import { AskResult } from '../platform/agent/claude' import { LoadedJourney } from '../journeys/steps' import { journeysFolderName } from '../journeys/journeys' -import { shortQ } from '../text' +import { shortQ } from '../core/text' import { relPath } from '../notes/location' import { walkJourney } from '../tour/commands' import { walk } from '../tour/instances' -import { clock, journeyPrompt, journeyRules, minutes } from '../writing' +import { clock, journeyPrompt, journeyRules, minutes } from '../core/writing' import { showClarify } from './clarify' import { bundledSkill, cliOrClipboard, journeyPy, modelLabel, runJourneySkill, skillAndModel, Staging, stagingFolder } from './claudeRun' import { startWriting, Writing } from './inProgress' diff --git a/test/anchor.test.ts b/test/anchor.test.ts index bffea69..3da79b7 100644 --- a/test/anchor.test.ts +++ b/test/anchor.test.ts @@ -1,8 +1,8 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { anchor } from '../src/anchor' -import { shift } from '../src/lineFollow' -import { lineDiff } from '../src/staleDiff' +import { anchor } from '../src/core/anchors/anchor' +import { shift } from '../src/core/anchors/lineFollow' +import { lineDiff } from '../src/core/anchors/staleDiff' const file = ['a', 'function f() {', ' return 1', '}', 'b', 'c'] diff --git a/test/answerLinks.test.ts b/test/answerLinks.test.ts index 4d5db68..edaddf9 100644 --- a/test/answerLinks.test.ts +++ b/test/answerLinks.test.ts @@ -1,7 +1,7 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { linkify } from '../src/linkifyAnswer' -import { linkTarget } from '../src/linkUri' +import { linkify } from '../src/core/linkifyAnswer' +import { linkTarget } from '../src/core/linkUri' const link = (t: string, f: string, l?: string) => `[${t}](cmd:${f}:${l ?? 1})` diff --git a/test/claude.test.ts b/test/claude.test.ts index 5699e6d..d2dceb0 100644 --- a/test/claude.test.ts +++ b/test/claude.test.ts @@ -2,7 +2,7 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import * as fs from 'fs' import * as path from 'path' -import { foldEvent, modelProblem } from '../src/claude' +import { foldEvent, modelProblem } from '../src/platform/agent/claude' test('folds a real `claude -p --output-format stream-json` transcript', () => { const lines = fs.readFileSync(path.join(__dirname, '../../test/fixtures/claude-stream.jsonl'), 'utf8').split('\n').filter(Boolean) diff --git a/test/coalesced.test.ts b/test/coalesced.test.ts index ddfb25a..e04c3c4 100644 --- a/test/coalesced.test.ts +++ b/test/coalesced.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { Coalesced } from '../src/coalesced' +import { Coalesced } from '../src/core/coalesced' const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)) diff --git a/test/codeBlocks.test.ts b/test/codeBlocks.test.ts index 031940b..bbc3328 100644 --- a/test/codeBlocks.test.ts +++ b/test/codeBlocks.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { Sym, blockAt, blocksFromSymbols, blocksFromText, groupSteps } from '../src/codeBlocks' +import { Sym, blockAt, blocksFromSymbols, blocksFromText, groupSteps } from '../src/core/codeBlocks' // A worker like the one in the example shop: consts at the top, functions with destructuring and callbacks inside. const worker = [ diff --git a/test/codeLinkText.test.ts b/test/codeLinkText.test.ts index f23e011..9e115fa 100644 --- a/test/codeLinkText.test.ts +++ b/test/codeLinkText.test.ts @@ -1,7 +1,7 @@ import test from 'node:test' import assert from 'node:assert/strict' -import { linkPhrases } from '../src/codeLinkText' -import { readLinks } from '../src/journeyModel' +import { linkPhrases } from '../src/core/codeLinkText' +import { readLinks } from '../src/core/format/journeyModel' const L = (phrase: string) => ({ phrase, file: 'a.go', start: 1, end: 1, text: '' }) diff --git a/test/compact.test.ts b/test/compact.test.ts index 4b8fa65..8e578e5 100644 --- a/test/compact.test.ts +++ b/test/compact.test.ts @@ -3,8 +3,8 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import fs from 'node:fs' import path from 'node:path' -import { blockHash, compactOf, CompactAnchor, findCompact, toCompact } from '../src/compact' -import { parseJourney } from '../src/journeyModel' +import { blockHash, compactOf, CompactAnchor, findCompact, toCompact } from '../src/core/anchors/compact' +import { parseJourney } from '../src/core/format/journeyModel' const file = [ 'package main', // 0 diff --git a/test/fixtures/journeyList.ts b/test/fixtures/journeyList.ts index 1d5cf34..6d7412f 100644 --- a/test/fixtures/journeyList.ts +++ b/test/fixtures/journeyList.ts @@ -1,7 +1,7 @@ -// 35 journeys over several areas (the size of a real team's list), as list items (src/journeyList.ts ListItem), for +// 35 journeys over several areas (the size of a real team's list), as list items (src/core/list/journeyList.ts ListItem), for // the list's unit tests (test/journeyList.test.ts) and the Journeys home harness (test/journey-list/shoot.mjs, which // loads the built out/test/fixtures/journeyList.js). -import type { ListItem } from '../../src/journeyList' +import type { ListItem } from '../../src/core/list/journeyList' /** The topics of each area: one journey per topic, "How work". */ const AREAS: Record = { diff --git a/test/git.test.ts b/test/git.test.ts index 5fb9a64..4bf0da9 100644 --- a/test/git.test.ts +++ b/test/git.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { statusBranch, statusPaths } from '../src/git' +import { statusBranch, statusPaths } from '../src/platform/git' test('git status v2 entries: their paths (renames: the new one), the branch', () => { const out = [ diff --git a/test/gitRenames.test.ts b/test/gitRenames.test.ts index f9fbef9..f20c9e7 100644 --- a/test/gitRenames.test.ts +++ b/test/gitRenames.test.ts @@ -4,7 +4,7 @@ import * as fs from 'fs' import * as os from 'os' import * as path from 'path' import { execFileSync } from 'child_process' -import { gitRenames } from '../src/gitRenames' +import { gitRenames } from '../src/platform/gitRenames' /** git in `repo` as a test user. */ const gitIn = (repo: string) => (...a: string[]) => { diff --git a/test/golden-journey.test.ts b/test/golden-journey.test.ts index 712b929..0808452 100644 --- a/test/golden-journey.test.ts +++ b/test/golden-journey.test.ts @@ -8,14 +8,14 @@ import * as fs from 'fs' import * as path from 'path' import * as vm from 'vm' import { expectGolden } from './golden' -import { Journey, parseJourney, readAnchor, readLinks, readValues, isGeneric, isOldFormat } from '../src/journeyModel' +import { Journey, parseJourney, readAnchor, readLinks, readValues, isGeneric, isOldFormat } from '../src/core/format/journeyModel' import { codeMarkOf, findMark, markCodeProblem, markShapeProblem, readMarks, walkMarks } from '../src/marks/model' -import { codeLinkMarkup, linkPhrases, PH } from '../src/codeLinkText' +import { codeLinkMarkup, linkPhrases, PH } from '../src/core/codeLinkText' import { capValue, escapeTags, linkPaths } from '../src/journeys/textFormat' import { dropAsides, refFiles, refsIn, shortPaths, staleText, stepText, StepRef, StepTextInput, TextJourney } from '../src/tour/stepText' import { captureStepAnchor, placeStep, StepAt, writtenAt } from '../src/journeys/steps' -import { matchScore, queryWords, scoreJourney, tellingWords } from '../src/match' -import { ageOf, areaOf, buildList, seeAlso, stamp } from '../src/journeyList' +import { matchScore, queryWords, scoreJourney, tellingWords } from '../src/core/list/match' +import { ageOf, areaOf, buildList, seeAlso, stamp } from '../src/core/list/journeyList' import { NOW, items } from './fixtures/journeyList' const AREA = 'journey' diff --git a/test/golden-notes.test.ts b/test/golden-notes.test.ts index 822644c..e79825f 100644 --- a/test/golden-notes.test.ts +++ b/test/golden-notes.test.ts @@ -5,10 +5,10 @@ import { test } from 'node:test' import * as fs from 'fs' import * as path from 'path' import { expectGolden } from './golden' -import { agentReadme, captureAnchor, folderProblem, merge, NoteData, parseNote, serialize, titleOf } from '../src/noteModel' -import { blockHash, compactOf, CompactAnchor, findCompact, toCompact } from '../src/compact' -import { anchor, closest, relocate } from '../src/anchor' -import { lineDiff, staleKind } from '../src/staleDiff' +import { agentReadme, captureAnchor, folderProblem, merge, NoteData, parseNote, serialize, titleOf } from '../src/core/format/noteModel' +import { blockHash, compactOf, CompactAnchor, findCompact, toCompact } from '../src/core/anchors/compact' +import { anchor, closest, relocate } from '../src/core/anchors/anchor' +import { lineDiff, staleKind } from '../src/core/anchors/staleDiff' const AREA = 'notes' const root = path.join(__dirname, '../..') diff --git a/test/golden-podcast.test.ts b/test/golden-podcast.test.ts index 16cf403..e009428 100644 --- a/test/golden-podcast.test.ts +++ b/test/golden-podcast.test.ts @@ -5,7 +5,7 @@ import { test } from 'node:test' import * as fs from 'fs' import * as path from 'path' import { expectGolden } from './golden' -import { Journey, parseJourney } from '../src/journeyModel' +import { Journey, parseJourney } from '../src/core/format/journeyModel' import { calmViews, chapterJump, chaptersOf, clock, clockMs, Episode, isPodcastFile, JourneyShape, markTimes, marksAt, marksOf, marksProblems, parsePodcast, planMarks, podcastFileOf, resolveEpisode, segmentAt, timeOf, viewAt } from '../src/podcast/model' import { audioPathProblem, brokenLinks, jsonSyntaxError, lineCol, locate, markFileNames, playNotice, validatePodcast } from '../src/podcast/validate' import { afterStep, remapTime, resumeTime } from '../src/podcast/resume' diff --git a/test/integration/check/journeysView.ts b/test/integration/check/journeysView.ts index df6c72f..7ab6061 100644 --- a/test/integration/check/journeysView.ts +++ b/test/integration/check/journeysView.ts @@ -1,5 +1,5 @@ // A guest in this suite: the Journeys view ("In this file", the search) is not part of the check, but this workspace -// (examples/shop) is the one with a journey in the repository (journeys/place-order.json). Source: src/journeyList.ts. +// (examples/shop) is the one with a journey in the repository (journeys/place-order.json). Source: src/core/list/journeyList.ts. import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' diff --git a/test/integration/main/animation.ts b/test/integration/main/animation.ts index a66ee01..ecd8711 100644 --- a/test/integration/main/animation.ts +++ b/test/integration/main/animation.ts @@ -1,7 +1,7 @@ // A step with code links, value hints and an animation (prototype): phrases of the card link to their lines; a // value hint shows what a variable holds in the example run; the row's toggle plays the scene in place of the map and // each beat lights the line that does it; back, forward and "Map" all work. Then: files opened over the panel move to -// the code group. Source: src/codeLinks.ts, src/codeLinkText.ts, src/valueHints.ts, src/beats.ts, src/lineFollow.ts, +// the code group. Source: src/codeLinks/codeLinks.ts, src/core/codeLinkText.ts, src/codeLinks/valueHints.ts, src/codeLinks/beats.ts, src/core/anchors/lineFollow.ts, // src/tour/card.ts; the panel's side in media/journey-scene.js (test/journey-scene/check.mjs). import * as vscode from 'vscode' import assert from 'assert' diff --git a/test/integration/main/journeyFiles.ts b/test/integration/main/journeyFiles.ts index d18fdf0..901632b 100644 --- a/test/integration/main/journeyFiles.ts +++ b/test/integration/main/journeyFiles.ts @@ -1,7 +1,7 @@ // A journey's files changing under it: the journey file deleted mid-walk, a step's file renamed (on disk, with git mv), // changed on disk with no editor open, refreshed by the journey writer; and a long file: the map follows the step, // cards stay in view after jumps, arriving at a step reads no note, leaving for another journey says so, a step whose -// file is gone opens no stand-in tab. Source: src/journeys/, src/gitRenames.ts, src/anchor.ts, src/compact.ts. +// file is gone opens no stand-in tab. Source: src/journeys/, src/platform/gitRenames.ts, src/core/anchors/anchor.ts, src/core/anchors/compact.ts. import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' diff --git a/test/integration/main/journeyMarks.ts b/test/integration/main/journeyMarks.ts index 7eaef46..1406a2a 100644 --- a/test/integration/main/journeyMarks.ts +++ b/test/integration/main/journeyMarks.ts @@ -1,4 +1,4 @@ -// Marks on a walked step (src/tour/stepMarks.ts, src/marks/lights.ts, src/tour/card.ts, src/beats.ts): opening the +// Marks on a walked step (src/tour/stepMarks.ts, src/marks/lights.ts, src/tour/card.ts, src/codeLinks/beats.ts): opening the // step lights its marks, each beat its own as the focus with the ones before dimmer; while there are marks the step's // lines get the thin grey bar and the beat's line no box; a mark not found near its lines lights nothing; marks follow // the step when code is inserted above it; a step without marks looks as it always did. CODE_NOTES_SHOTS: the step diff --git a/test/integration/main/journeyTour.ts b/test/integration/main/journeyTour.ts index 5196f55..7d2ddf2 100644 --- a/test/integration/main/journeyTour.ts +++ b/test/integration/main/journeyTour.ts @@ -1,6 +1,6 @@ // Walking a journey (format v2): it loads (steps are never notes), opens as a map with step cards in the editor, // follows edits, takes questions, survives reloads and edits of its file, and leaves "◇ Step n" lenses behind. -// Source: src/journeys/ (loading, where the steps are), src/journeyModel.ts (parsing), src/tour/ (the walk, cards, +// Source: src/journeys/ (loading, where the steps are), src/core/format/journeyModel.ts (parsing), src/tour/ (the walk, cards, // lenses, commands). import * as vscode from 'vscode' import * as fs from 'fs' diff --git a/test/integration/main/keysAndMap.ts b/test/integration/main/keysAndMap.ts index e2db86f..eb536ed 100644 --- a/test/integration/main/keysAndMap.ts +++ b/test/integration/main/keysAndMap.ts @@ -1,6 +1,6 @@ // The chord keys (Ctrl+< / Ctrl+' with C R D A V), the tutorial's extension side, and the whole map: step numbers, // function boxes and the "‹ Journeys" home list. Source: package.json (keybindings), src/tour/ (next/previous, -// the panel's messages: tour/mapMessages.ts), src/tutorialSpot.ts, media/journey-map.js and +// the panel's messages: tour/mapMessages.ts), src/tour/tutorialSpot.ts, media/journey-map.js and // media/journey-tutorial.js (driven through their own click/key handlers). // The tutorial's webview side (bar and card texts, where the cards sit, clicks blocked under it) is checked in the // panel harness, test/journey-map/shoot.mjs (`tutorial`); here: what the extension does with it. diff --git a/test/integration/main/listenEditor.ts b/test/integration/main/listenEditor.ts index 468c2b0..806519e 100644 --- a/test/integration/main/listenEditor.ts +++ b/test/integration/main/listenEditor.ts @@ -1,4 +1,4 @@ -// The editor while it plays (src/tour/card.ts, instances.ts, src/beats.ts, src/podcast/marks.ts, src/notes/decorations.ts): +// The editor while it plays (src/tour/card.ts, instances.ts, src/codeLinks/beats.ts, src/podcast/marks.ts, src/notes/decorations.ts): // the step card is its header line only, above the function the step is in; the marks are the only coloured thing on // the code (no step tint, no beat box, no note bars, no value hints, no ruler ticks). On pause all of it comes back and // the card is the full one above the step's first line. CODE_NOTES_SHOTS: pictures, playing and paused, dark and light. diff --git a/test/integration/main/notes.ts b/test/integration/main/notes.ts index 7658af9..7414eb5 100644 --- a/test/integration/main/notes.ts +++ b/test/integration/main/notes.ts @@ -1,7 +1,7 @@ // Notes, from the first one to the trash: adding, agent replies and unread counts, following the code (edits, renames, // deletes), resolving, sessions, invalid files, Ask Claude, paths outside the workspace, .gitignore. -// Source: src/notes/ (commands; following code: notes/location.ts), src/threads/ (threads), src/store.ts (files, -// trash), src/seen.ts (unread), src/anchor.ts (finding lines), src/ask/ and src/claude.ts (Ask Claude). +// Source: src/notes/ (commands; following code: notes/location.ts), src/threads/ (threads), src/notes/store.ts (files, +// trash), src/notes/seen.ts (unread), src/core/anchors/anchor.ts (finding lines), src/ask/ and src/platform/agent/claude.ts (Ask Claude). import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' diff --git a/test/integration/main/notesReview.ts b/test/integration/main/notesReview.ts index efc9ff8..a94db0d 100644 --- a/test/integration/main/notesReview.ts +++ b/test/integration/main/notesReview.ts @@ -1,6 +1,6 @@ // Notes as review findings: R (resolve and next), severity order and icons, grouping by session or file, the // history of resolves and reopens, suggestions with Apply, file and folder notes, Add Note without commenting ranges. -// Source: src/notes/ (commands, suggestions), src/threads/, src/sidebar/ (the tree), src/noteModel.ts (events, +// Source: src/notes/ (commands, suggestions), src/threads/, src/sidebar/ (the tree), src/core/format/noteModel.ts (events, // unknown fields kept). import * as vscode from 'vscode' import * as fs from 'fs' diff --git a/test/integration/main/repoJourneys.ts b/test/integration/main/repoJourneys.ts index caf156d..571ad94 100644 --- a/test/integration/main/repoJourneys.ts +++ b/test/integration/main/repoJourneys.ts @@ -1,6 +1,6 @@ // Journeys kept in the repository (/journeys/, the codeNotes.journeys.folder setting) with compact (v3) anchors: // read once even when a personal copy has the same id; a block that moved is found fresh, one edited inside is -// "changed", one deleted is "gone". Source: src/journeys/, src/compact.ts. +// "changed", one deleted is "gone". Source: src/journeys/, src/core/anchors/compact.ts. import * as fs from 'fs' import * as path from 'path' import assert from 'assert' diff --git a/test/integration/main/requests.ts b/test/integration/main/requests.ts index 9d84cf3..859279d 100644 --- a/test/integration/main/requests.ts +++ b/test/integration/main/requests.ts @@ -1,8 +1,8 @@ // Asking for a journey from outside the window: the request file (.code-notes/.request.json, written by a script or // another tool, answered in .result.json) and vscode:///explain links. A match opens; no match asks // first and then writes one with Claude (or Claude asks back); a link never starts Claude. -// Source: src/write/requests.ts (requests, links), src/write/rank.ts (the confirm and pick), src/match.ts (matching), -// src/writing.ts. +// Source: src/write/requests.ts (requests, links), src/write/rank.ts (the confirm and pick), src/core/list/match.ts (matching), +// src/core/writing.ts. import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' diff --git a/test/integration/main/shared.ts b/test/integration/main/shared.ts index d4a8b8e..2427589 100644 --- a/test/integration/main/shared.ts +++ b/test/integration/main/shared.ts @@ -3,7 +3,7 @@ // (written by keysAndMap.ts, resolved by notesReview.ts). Builders for any journey or note: ../fixtures.ts. import * as fs from 'fs' import * as path from 'path' -import { compactOf } from '../../../src/compact' +import { compactOf } from '../../../src/core/anchors/compact' import { StepFixture, journey, step } from '../fixtures' import { journeysDir, wsPath } from './context' diff --git a/test/integration/main/writeJourney.ts b/test/integration/main/writeJourney.ts index 52a53f5..c94883d 100644 --- a/test/integration/main/writeJourney.ts +++ b/test/integration/main/writeJourney.ts @@ -1,6 +1,6 @@ // "Ask the agent to write a journey" when nothing matches: the fake claude CLI (test/fixtures/fake-claude.js) plays // the code-journey skill's journey.py; the journey is staged, checked, moved into journeys/, and its map opens. -// Source: src/writing.ts (staging), src/claude.ts (the CLI's arguments), src/write/ (claudeRun.ts, writeJourney.ts). +// Source: src/core/writing.ts (staging), src/platform/agent/claude.ts (the CLI's arguments), src/write/ (claudeRun.ts, writeJourney.ts). import * as fs from 'fs' import * as path from 'path' import assert from 'assert' diff --git a/test/journey-list/shoot.mjs b/test/journey-list/shoot.mjs index ea9a5f4..42d24b3 100644 --- a/test/journey-list/shoot.mjs +++ b/test/journey-list/shoot.mjs @@ -4,7 +4,7 @@ // Checks), "In " capped with "Show n more", a row click selects and previews (stale steps marked, Refresh), // the keyboard (↓ from the search into the rows, a visible focus ring, the focused row in view, chips one Tab stop // with ← →), Enter walks, Esc clears then goes back, "‹ Journeys" from a walk selects that journey, the heading is the -// short title. The extension's part (the model) is out/src/journeyList.js, run here. +// short title. The extension's part (the model) is out/src/core/list/journeyList.js, run here. // Usage (after `npm run build`): node test/journey-list/shoot.mjs [screenshot-dir] (PLAYWRIGHT=…, CHROME=… as in journey-map) import fs from 'node:fs' import path from 'node:path' @@ -15,7 +15,7 @@ const pw = await import(process.env.PLAYWRIGHT ? pathToFileURL(path.resolve(proc const chromium = pw.chromium ?? pw.default.chromium const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..') const require = createRequire(import.meta.url) -const { buildList } = require(path.join(ROOT, 'out/src/journeyList.js')) +const { buildList } = require(path.join(ROOT, 'out/src/core/list/journeyList.js')) const { items, NOW } = require(path.join(ROOT, 'out/test/fixtures/journeyList.js')) const OUT = process.argv[2] ? path.resolve(process.argv[2]) : '' if (OUT) fs.mkdirSync(OUT, { recursive: true }) diff --git a/test/journey-map/harness.html b/test/journey-map/harness.html index de0d4ee..c2ac39f 100644 --- a/test/journey-map/harness.html +++ b/test/journey-map/harness.html @@ -27,7 +27,7 @@ var JourneyModel = exports - + diff --git a/test/journey-map/shoot.mjs b/test/journey-map/shoot.mjs index 537a7ab..1f9a4aa 100644 --- a/test/journey-map/shoot.mjs +++ b/test/journey-map/shoot.mjs @@ -26,7 +26,7 @@ const SAMPLES = path.join(ROOT, 'test/fixtures/journey/journeys') const HARNESS = pathToFileURL(path.join(ROOT, 'test/journey-map/harness.html')).href /** Run in each page before its own scripts: the contrast helpers (window.contrast) and the layout rules `check` uses. */ const PAGE_HELPERS = [path.join(ROOT, 'test/harness/contrast.js'), path.join(ROOT, 'test/journey-map/layoutChecks.js')] -for (const f of [path.join(ROOT, 'out/src/journeyModel.js'), path.join(ROOT, 'out/vendor/elk.bundled.js')]) { +for (const f of [path.join(ROOT, 'out/src/core/format/journeyModel.js'), path.join(ROOT, 'out/vendor/elk.bundled.js')]) { if (!fs.existsSync(f)) { console.error(`${path.relative(ROOT, f)} is missing: run \`npm run build\` first`); process.exit(2) } } @@ -107,7 +107,7 @@ const list = (extra.length ? extra : ['place-order.json', 'other.json']).map((f, ...(i === 1 ? { start: true } : {}), })) // The home's model, as the extension builds it from the same journeys (journeyList.ts). -const { buildList } = (await import(pathToFileURL(path.join(ROOT, 'out/src/journeyList.js')).href)).default +const { buildList } = (await import(pathToFileURL(path.join(ROOT, 'out/src/core/list/journeyList.js')).href)).default const homeModel = buildList(list.map((x) => ({ key: x.key, kind: 'journey', title: x.title, question: x.question, summary: '', files: ['web/a.js'], stepTitles: [], steps: x.steps, stale: 0, isNew: false, resume: x.resume, ...(x.start ? { start: true } : {}), diff --git a/test/journeyList.test.ts b/test/journeyList.test.ts index f825d5d..7dc36df 100644 --- a/test/journeyList.test.ts +++ b/test/journeyList.test.ts @@ -1,8 +1,8 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { HERE_CAP, ListItem, ageOf, areaOf, buildList, seeAlso } from '../src/journeyList' +import { HERE_CAP, ListItem, ageOf, areaOf, buildList, seeAlso } from '../src/core/list/journeyList' import { NOW, items } from './fixtures/journeyList' -// The word-level rules the list's search uses (queryWords, stem, matchScore: src/match.ts) are tested in match.test.ts. +// The word-level rules the list's search uses (queryWords, stem, matchScore: src/core/list/match.ts) are tested in match.test.ts. /** A journey item titled `title` whose steps (all in api/x.js) have these titles. */ const journeyItem = (key: string, title: string, steps: string[], summary = ''): ListItem => ({ diff --git a/test/journeyModel.test.ts b/test/journeyModel.test.ts index e3bbdbf..7d0526e 100644 --- a/test/journeyModel.test.ts +++ b/test/journeyModel.test.ts @@ -2,8 +2,8 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import * as fs from 'fs' import * as path from 'path' -import { staleKind } from '../src/staleDiff' -import { Journey, parseJourney, readValues } from '../src/journeyModel' +import { staleKind } from '../src/core/anchors/staleDiff' +import { Journey, parseJourney, readValues } from '../src/core/format/journeyModel' import { capValue, escapeTags, linkPaths } from '../src/journeys/textFormat' const fixture = fs.readFileSync(path.join(__dirname, '../../test/fixtures/journey/journeys/place-order.json'), 'utf8') diff --git a/test/journeySteps.test.ts b/test/journeySteps.test.ts index ec92d9a..8b6ffad 100644 --- a/test/journeySteps.test.ts +++ b/test/journeySteps.test.ts @@ -1,10 +1,10 @@ // Where a journey's steps are (src/journeys/steps.ts): carried over a reload, captured anchors, placed in new lines. import { test } from 'node:test' import assert from 'node:assert/strict' -import { parseJourney, Journey } from '../src/journeyModel' -import { compactOf } from '../src/compact' +import { parseJourney, Journey } from '../src/core/format/journeyModel' +import { compactOf } from '../src/core/anchors/compact' import { LoadedJourney, StepAt, captureStepAnchor, carryPositions, fileOf, isEmptyAnchor, journeyById, placeStep, posKey, sameStepAt, writtenAt } from '../src/journeys/steps' -import { dirPath, pathIn } from '../src/paths' +import { dirPath, pathIn } from '../src/core/paths' const code = ['import x', '', 'function f() {', ' a()', ' x()', ' y()', ' b()', '}', '', 'function g() {}'] const journey = (steps: object[]) => parseJourney(JSON.stringify({ version: 2, nodes: [{ id: 'n', label: 'N' }], steps }), 'j') as Journey diff --git a/test/layout.test.ts b/test/layout.test.ts index a69f123..99620e5 100644 --- a/test/layout.test.ts +++ b/test/layout.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { codeWidth, listeningShare, panelShare } from '../src/panelWidth' +import { codeWidth, listeningShare, panelShare } from '../src/core/panelWidth' test('the code\'s 80 columns count the gutter, the scrollbar and the minimap', () => { // Measured in VS Code at 14 px: a 733 px editor (gutter 83 px, minimap on) showed 66 columns. diff --git a/test/lineFollow.test.ts b/test/lineFollow.test.ts index 044eefd..ed6c8a9 100644 --- a/test/lineFollow.test.ts +++ b/test/lineFollow.test.ts @@ -1,6 +1,6 @@ import test from 'node:test' import assert from 'node:assert/strict' -import { LineEdit, findLine, followLine, shiftLine } from '../src/lineFollow' +import { LineEdit, findLine, followLine, shiftLine } from '../src/core/anchors/lineFollow' test('findLine: the written line, the nearest moved one, or gone', () => { const lines = ['a()', ' store(run)', 'b()', ' store(run)', 'c()'] diff --git a/test/match.test.ts b/test/match.test.ts index 92eb24e..cd49d44 100644 --- a/test/match.test.ts +++ b/test/match.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { matchScore, queryWords, scoreJourney, stem, tellingWords, STOP } from '../src/match' +import { matchScore, queryWords, scoreJourney, stem, tellingWords, STOP } from '../src/core/list/match' import { items } from './fixtures/journeyList' // ---------- the Journeys list's search (matchScore, queryWords) ---------- diff --git a/test/noteModel.test.ts b/test/noteModel.test.ts index a45c6b5..94709e8 100644 --- a/test/noteModel.test.ts +++ b/test/noteModel.test.ts @@ -1,7 +1,7 @@ -// A note file's content (src/noteModel.ts): reading, writing, the three-way merge, the notes folder setting. +// A note file's content (src/core/format/noteModel.ts): reading, writing, the three-way merge, the notes folder setting. import { test } from 'node:test' import assert from 'node:assert/strict' -import { NoteData, agentReadme, captureAnchor, folderProblem, merge, parseNote, serialize, titleOf } from '../src/noteModel' +import { NoteData, agentReadme, captureAnchor, folderProblem, merge, parseNote, serialize, titleOf } from '../src/core/format/noteModel' const note = (o: Record = {}) => JSON.stringify({ file: 'src/a.ts', range: { start: 3, end: 5 }, status: 'open', messages: [{ author: 'ann', role: 'human', body: 'Why?' }], ...o, diff --git a/test/paths.test.ts b/test/paths.test.ts index ada1133..bd9392e 100644 --- a/test/paths.test.ts +++ b/test/paths.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { placeFile, settingFolder } from '../src/paths' +import { placeFile, settingFolder } from '../src/core/paths' const root = '/home/dev/shop' diff --git a/test/tourStepText.test.ts b/test/tourStepText.test.ts index b8dbdd9..5eb4ae1 100644 --- a/test/tourStepText.test.ts +++ b/test/tourStepText.test.ts @@ -3,7 +3,7 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import * as fs from 'fs' import * as path from 'path' -import { Journey, JStep, parseJourney } from '../src/journeyModel' +import { Journey, JStep, parseJourney } from '../src/core/format/journeyModel' import { parseBare, refFiles, StepRef, StepTextInput, TextJourney, staleText, stepText } from '../src/tour/stepText' import type { StepAt } from '../src/journeys/steps' diff --git a/test/workspaceFs.test.ts b/test/workspaceFs.test.ts index d013371..7fc4894 100644 --- a/test/workspaceFs.test.ts +++ b/test/workspaceFs.test.ts @@ -8,12 +8,12 @@ import * as path from 'path' const SRC = path.join(__dirname, '../../src') test('no vscode.workspace.fs outside workspaceFs.ts (src/ and its folders)', () => { - const sources = (fs.readdirSync(SRC, { recursive: true }) as string[]).filter((f) => f.endsWith('.ts') && f !== 'workspaceFs.ts') + const sources = (fs.readdirSync(SRC, { recursive: true }) as string[]).filter((f) => f.endsWith('.ts') && f !== path.join('platform', 'workspaceFs.ts')) const lines = sources.flatMap((f) => fs.readFileSync(path.join(SRC, f), 'utf8').split('\n').map((l, i) => [f, i + 1, l] as const)) const hits = lines.filter(([, , l]) => /workspace\.fs\b/.test(l)).map(([f, i]) => `${f}:${i}`) assert.deepEqual(hits, []) }) test('no vscode.workspace.openTextDocument just to read lines in the step paths (code links, value hints)', () => { - for (const f of ['codeLinks.ts', 'valueHints.ts']) assert.ok(!/openTextDocument/.test(fs.readFileSync(path.join(SRC, f), 'utf8')), f) + for (const f of ['codeLinks/codeLinks.ts', 'codeLinks/valueHints.ts']) assert.ok(!/openTextDocument/.test(fs.readFileSync(path.join(SRC, f), 'utf8')), f) }) diff --git a/test/writing.test.ts b/test/writing.test.ts index 40ea764..24c323f 100644 --- a/test/writing.test.ts +++ b/test/writing.test.ts @@ -1,6 +1,6 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { clock, journeyPrompt, minutes, phaseOf } from '../src/writing' +import { clock, journeyPrompt, minutes, phaseOf } from '../src/core/writing' import { bashCall } from './toolCalls' test('elapsed time and a plain phase from journey.py commands', () => { From 88c9fb5b9797c9b63c44524b539cdff09ece6273 Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:51:11 +0100 Subject: [PATCH 2/8] One build script: scripts/build.mjs runs tsc, then a file per target --- .vscode/tasks.json | 2 +- scripts/build.mjs | 23 +++++++++++++++++++++++ scripts/build/cli.mjs | 9 +++++++++ scripts/build/pages.mjs | 10 ++++++++++ scripts/build/vendor.mjs | 10 ++++++++++ src/webview/page.ts | 4 ++-- test/journey-scene/check.mjs | 2 +- 7 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 scripts/build.mjs create mode 100644 scripts/build/cli.mjs create mode 100644 scripts/build/pages.mjs create mode 100644 scripts/build/vendor.mjs diff --git a/.vscode/tasks.json b/.vscode/tasks.json index dcb8154..50be1cb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ { "label": "code-notes: watch", "type": "shell", - "command": "npm run -s vendor && npm run -s pages && npx tsc -w -p .", + "command": "npm run -s watch", "isBackground": true, "problemMatcher": "$tsc-watch", "presentation": { "reveal": "never" } diff --git a/scripts/build.mjs b/scripts/build.mjs new file mode 100644 index 0000000..909c970 --- /dev/null +++ b/scripts/build.mjs @@ -0,0 +1,23 @@ +// npm run build: compiles the extension and its tests (tsc -p .), then runs every scripts/build/*.mjs in name order, +// each one build target (the CLI bundle, the vendored libraries, the webview pages). +// npm run watch (the F5 task in .vscode/tasks.json): the same targets once, then tsc in watch mode. +import { spawnSync } from 'node:child_process' +import fs from 'node:fs' +import path from 'node:path' +import { createRequire } from 'node:module' +import { fileURLToPath } from 'node:url' + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') +const tsc = createRequire(import.meta.url).resolve('typescript/bin/tsc') +const watch = process.argv.includes('--watch') + +/** Runs `node ` in the repository root; exits with its status when it fails. */ +function node(...args) { + const r = spawnSync(process.execPath, args, { cwd: root, stdio: 'inherit' }) + if (r.status !== 0) process.exit(r.status ?? 1) +} + +if (!watch) node(tsc, '-p', '.') +const dir = path.join(root, 'scripts', 'build') +for (const step of fs.readdirSync(dir).filter((n) => n.endsWith('.mjs')).sort()) node(path.join(dir, step)) +if (watch) node(tsc, '-w', '-p', '.') diff --git a/scripts/build/cli.mjs b/scripts/build/cli.mjs new file mode 100644 index 0000000..e62663c --- /dev/null +++ b/scripts/build/cli.mjs @@ -0,0 +1,9 @@ +// The understanding CLI: cli/understanding.mjs, one file bundled from cli/understanding/ (committed; CI recipes +// download it by URL). +import { spawnSync } from 'node:child_process' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..') +const r = spawnSync(process.execPath, [path.join(root, 'cli/bundle.mjs')], { cwd: root, stdio: 'inherit' }) +process.exit(r.status ?? 1) diff --git a/scripts/build/pages.mjs b/scripts/build/pages.mjs new file mode 100644 index 0000000..02c32ca --- /dev/null +++ b/scripts/build/pages.mjs @@ -0,0 +1,10 @@ +// The webview pages' HTML (src/webview/*.html) next to the compiled page.ts that reads them (out/src/webview/). +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..') +const from = path.join(root, 'src/webview') +const to = path.join(root, 'out/src/webview') +fs.mkdirSync(to, { recursive: true }) +for (const n of fs.readdirSync(from)) if (n.endsWith('.html')) fs.copyFileSync(path.join(from, n), path.join(to, n)) diff --git a/scripts/build/vendor.mjs b/scripts/build/vendor.mjs new file mode 100644 index 0000000..b736407 --- /dev/null +++ b/scripts/build/vendor.mjs @@ -0,0 +1,10 @@ +// The libraries the webview pages load from out/vendor/: ELK (the map's layout) and its licence. +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..') +const out = path.join(root, 'out/vendor') +fs.mkdirSync(out, { recursive: true }) +fs.copyFileSync(path.join(root, 'node_modules/elkjs/lib/elk.bundled.js'), path.join(out, 'elk.bundled.js')) +fs.copyFileSync(path.join(root, 'node_modules/elkjs/LICENSE.md'), path.join(out, 'elk-LICENSE.md')) diff --git a/src/webview/page.ts b/src/webview/page.ts index 0061bcd..d142806 100644 --- a/src/webview/page.ts +++ b/src/webview/page.ts @@ -1,8 +1,8 @@ // Webview pages, in one place: text escaped for HTML, a nonce for their scripts, and the page around a view's own files // (webviewPage), with its Content-Security-Policy (contentSecurityPolicy: the extension's styles and fonts, only the // scripts carrying the nonce). A page's markup may be kept as a .html file next to this one (copied to out/ by -// `npm run pages`) and filled in where it says {{name}} (pageBody). cli/understanding.mjs builds no webview, so it -// needs none of this. +// scripts/build/pages.mjs) and filled in where it says {{name}} (pageBody). cli/understanding.mjs builds no webview, +// so it needs none of this. import * as fs from 'fs' import * as path from 'path' diff --git a/test/journey-scene/check.mjs b/test/journey-scene/check.mjs index b4c553b..0c8388f 100644 --- a/test/journey-scene/check.mjs +++ b/test/journey-scene/check.mjs @@ -6,7 +6,7 @@ // node test/journey-scene/check.mjs [] // Needs Playwright with Chromium: `playwright` is imported from node_modules unless PLAYWRIGHT is set to another // install's playwright/index.mjs; CHROME, when set, is the Chromium or Chrome binary to launch (else Playwright's own). -// The panel's harness (test/journey-map/harness.html) loads out/vendor/elk.bundled.js: run `npm run vendor` first. +// The panel's harness (test/journey-map/harness.html) loads out/vendor/elk.bundled.js: run `npm run build` first. // Try it on the bundled sample: node test/journey-scene/check.mjs test/journey-scene/sample.json /tmp/shots import fs from 'node:fs' import path from 'node:path' From bd4139279449d9ce64a85334eee0deaae5ec0340 Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:51:11 +0100 Subject: [PATCH 3/8] Lint: ESLint, and a check of the layers of src/ and their import cycles --- eslint.config.mjs | 69 ++++++++++ scripts/check-layers.mjs | 178 +++++++++++++++++++++++++ scripts/layer-exceptions/README.md | 24 ++++ scripts/layer-exceptions/ask.txt | 6 + scripts/layer-exceptions/check.txt | 5 + scripts/layer-exceptions/codeLinks.txt | 2 + scripts/layer-exceptions/core.txt | 4 + scripts/layer-exceptions/journeys.txt | 2 + scripts/layer-exceptions/notes.txt | 50 +++++++ scripts/layer-exceptions/platform.txt | 2 + scripts/layer-exceptions/podcast.txt | 6 + scripts/layer-exceptions/sidebar.txt | 9 ++ scripts/layer-exceptions/threads.txt | 6 + scripts/layer-exceptions/tour.txt | 29 ++++ scripts/layer-exceptions/write.txt | 10 ++ scripts/layers.json | 13 ++ test/layers.test.ts | 116 ++++++++++++++++ test/workspaceFs.test.ts | 46 +++++-- 18 files changed, 566 insertions(+), 11 deletions(-) create mode 100644 eslint.config.mjs create mode 100644 scripts/check-layers.mjs create mode 100644 scripts/layer-exceptions/README.md create mode 100644 scripts/layer-exceptions/ask.txt create mode 100644 scripts/layer-exceptions/check.txt create mode 100644 scripts/layer-exceptions/codeLinks.txt create mode 100644 scripts/layer-exceptions/core.txt create mode 100644 scripts/layer-exceptions/journeys.txt create mode 100644 scripts/layer-exceptions/notes.txt create mode 100644 scripts/layer-exceptions/platform.txt create mode 100644 scripts/layer-exceptions/podcast.txt create mode 100644 scripts/layer-exceptions/sidebar.txt create mode 100644 scripts/layer-exceptions/threads.txt create mode 100644 scripts/layer-exceptions/tour.txt create mode 100644 scripts/layer-exceptions/write.txt create mode 100644 scripts/layers.json create mode 100644 test/layers.test.ts diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..e5e4aa5 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,69 @@ +// npm run lint: ESLint over the extension (src/), the tests (test/), the CLI sources (cli/) and the build scripts +// (scripts/). The webview pages (media/) are not linted yet. The layer and cycle rule is scripts/check-layers.mjs. +import js from '@eslint/js' +import tseslint from 'typescript-eslint' + +/** Node's globals for the .mjs/.js scripts (written out: no extra dependency for them). */ +const NODE = Object.fromEntries(['process', 'console', 'Buffer', 'URL', 'URLSearchParams', 'setTimeout', 'clearTimeout', + 'setInterval', 'clearInterval', 'setImmediate', 'queueMicrotask', 'structuredClone', 'fetch', 'AbortController', + 'AbortSignal', 'TextEncoder', 'TextDecoder', 'require', 'module', 'exports', '__dirname', '__filename', 'performance', +].map((g) => [g, 'readonly'])) + +// From a remote extension host every vscode.workspace.fs call is a round trip through the window: the extension's own +// files go through platform/workspaceFs.ts (Node's fs for file: URIs) instead. +const WORKSPACE_FS = { + selector: "MemberExpression[property.name='fs']:matches([object.name='workspace'], [object.property.name='workspace'])", + message: 'Read and write files through platform/workspaceFs.ts, not vscode.workspace.fs.', +} +// The step paths (code links, value hints) read a file's lines through platform/documents.ts, not by opening it as a +// document. +const OPEN_DOCUMENT = { + selector: "MemberExpression[property.name='openTextDocument']", + message: 'Code links and value hints read lines without opening a document.', +} + +export default tseslint.config( + { ignores: ['out/**', 'node_modules/**', '.vscode-test/**', 'media/**', 'examples/**', 'skills/**', 'cli/understanding.mjs'] }, + js.configs.recommended, + ...tseslint.configs.recommended, + { + // The code carries disable comments for rules that are off below; they come back into use as the rules go on. + linterOptions: { reportUnusedDisableDirectives: 'off' }, + rules: { + // Recommended rules the code does not pass yet, off until the slice owning the code fixes it: + '@typescript-eslint/no-explicit-any': 'off', // ~56 `any` casts, mostly at the vscode API and in tests + '@typescript-eslint/no-unused-vars': 'off', // ~15 unused names in the CLI and its tests + '@typescript-eslint/no-require-imports': 'off', // the CommonJS fixtures (fake claude, fake grader) and a lazy require + '@typescript-eslint/no-unused-expressions': 'off', // one `c ? f() : g()` statement in the notes filter + 'no-useless-assignment': 'off', // 6 initial values that later code overwrites before reading + 'no-control-regex': 'off', // the answer linkifier marks kept spans with NUL characters on purpose + 'no-irregular-whitespace': 'off', // text.ts's right-to-left character range holds U+FEFF literally + 'no-regex-spaces': 'off', // one regex in a CLI test matches aligned output + }, + }, + { + files: ['**/*.ts'], + languageOptions: { parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname } }, + rules: { + // Off until the ~186 un-awaited promises are handled (each awaited, or marked `void` with a reason): the + // platform slice turns it on. + '@typescript-eslint/no-floating-promises': 'off', + }, + }, + { + files: ['src/**/*.ts'], + ignores: ['src/platform/workspaceFs.ts'], + rules: { 'no-restricted-syntax': ['error', WORKSPACE_FS] }, + }, + { + files: ['src/codeLinks/codeLinks.ts', 'src/codeLinks/valueHints.ts'], + rules: { 'no-restricted-syntax': ['error', WORKSPACE_FS, OPEN_DOCUMENT] }, + }, + { files: ['**/*.mjs', '**/*.js'], languageOptions: { globals: NODE } }, + { + // The screenshot drivers and harness pages run code in the browser (page.evaluate, diff --git a/test/docs.test.ts b/test/docs.test.ts new file mode 100644 index 0000000..0d75bca --- /dev/null +++ b/test/docs.test.ts @@ -0,0 +1,31 @@ +// The CI recipes in docs/understanding-check.md, which people copy into their repositories: they must download the +// CLI of this version and pin the actions to the same commits as this repository's own CI. +import { test } from 'node:test' +import assert from 'node:assert/strict' +import * as fs from 'fs' +import * as path from 'path' + +const ROOT = path.join(__dirname, '../..') +const read = (f: string) => fs.readFileSync(path.join(ROOT, f), 'utf8') +const doc = read('docs/understanding-check.md') + +test('the recipes download cli/understanding.mjs of this version', () => { + const version = JSON.parse(read('package.json')).version + const tags = [...doc.matchAll(/raw\.githubusercontent\.com\/tomeyer97\/code-notes\/([^/]+)\/cli\/understanding\.mjs/g)].map((m) => m[1]) + assert.ok(tags.length >= 2, 'a GitLab and a GitHub recipe') + assert.deepEqual([...new Set(tags)], [`v${version}`]) + assert.ok(doc.includes(`(\`v${version}\`, this version)`), 'the line above the recipes names the version too') +}) + +test('the recipes pin each action to the commit this repository\'s CI uses', () => { + const ours = new Map() + for (const f of ['.github/workflows/ci.yml', '.github/workflows/release.yml', '.github/actions/setup/action.yml']) { + for (const m of read(f).matchAll(/uses: ([\w-]+\/[\w-]+)@(\S+)/g)) ours.set(m[1], m[2]) + } + const used = [...doc.matchAll(/uses: ([\w-]+\/[\w-]+)@(\S+)/g)] + assert.ok(used.length, 'the GitHub recipe uses actions') + for (const [, action, ref] of used) { + assert.match(ref, /^[0-9a-f]{40}$/, `${action}: pinned to a commit`) + assert.equal(ref, ours.get(action), `${action}: the commit this repository's CI uses`) + } +})