Skip to content

Commit 0744437

Browse files
authored
Merge pull request #176 from pajoma/feature/updates
Upgrade to VS Code 1.118 baseline + vscode.l10n migration
2 parents be8065d + 504c06e commit 0744437

55 files changed

Lines changed: 4297 additions & 2272 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ jobs:
1212
lint-build-test:
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 20
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
node-version: ["20", "22"]
1519

1620
steps:
1721
- name: Checkout
1822
uses: actions/checkout@v4
1923

20-
- name: Setup Node.js
24+
- name: Setup Node.js ${{ matrix.node-version }}
2125
uses: actions/setup-node@v4
2226
with:
23-
node-version: "20"
27+
node-version: ${{ matrix.node-version }}
2428
cache: npm
2529

2630
- name: Install dependencies

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@
99
* Rework the whole syntax highlighting (it's a mess)
1010
* More code actions and code lenses (e.g. to pull all open tasks to the current journal entry)
1111

12+
## Unreleased
13+
14+
### Changed
15+
* Bumped VS Code engine baseline to `^1.118.0` (was `^1.94.0`). `@types/vscode` and toolchain (TypeScript 5.9, ESLint 9.39, esbuild 0.28, `@vscode/test-cli` 0.0.12, `@vscode/test-electron` 2.5, Mocha 11, `@typescript-eslint/*` 8.59) bumped to current stable.
16+
* Migrated translations from the custom `src/ext/messages.json` system to the stable `vscode.l10n` API. Manifest strings live in `package.nls*.json`; runtime strings in `l10n/bundle.l10n*.json`. All 11 locales preserved (en, de, fr, es, it, pt, nl, ru, zh, ja, ar). Fixed a moment.js escape bug in the Spanish locale carried over from `messages.json`.
17+
18+
### Removed
19+
* Redundant `activationEvents` block — implicit activation has covered all `contributes.commands` since VS Code 1.74.
20+
* Unused `@vscode/extension-telemetry` runtime dependency.
21+
* Internal `journal.test` command (was undocumented and never registered).
22+
23+
### Added
24+
* `capabilities.virtualWorkspaces` (`limited`) and `capabilities.untrustedWorkspaces` (`limited` with `restrictedConfigurations: ["journal.base"]`) in the manifest.
25+
* `@vscode/l10n-dev` devDependency and `npm run l10n:export` script for regenerating the runtime bundle.
26+
* Node 22 to the CI matrix alongside Node 20.
27+
1228
## 1.0.2
1329
* [Issue #136](https://github.com/pajoma/vscode-journal/issues/136) Added a configuration option to disable syntax highlighting (disabled by default)
1430
## 1.0.1

CLAUDE.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project
6+
7+
VS Code extension (`pajoma.vscode-journal`) for daily markdown journaling. TypeScript, bundled with esbuild, runs in the workspace extension host. Requires Node 20+ and VS Code 1.118+.
8+
9+
## Commands
10+
11+
```bash
12+
npm install
13+
npm run compile # esbuild → dist/extension.js (CJS, external 'vscode')
14+
npm run watch # esbuild watch (used as preLaunchTask for F5)
15+
npm run package # production build (minified, no sourcemap)
16+
npm run compile-tests # tsc -p . --outDir out (separate from extension bundle)
17+
npm run lint # eslint src
18+
npm test # @vscode/test-cli — pretest auto-runs compile-tests + compile + lint
19+
npm run check # lint + compile + test
20+
```
21+
22+
Run a single test by passing a Mocha grep through `@vscode/test-cli`:
23+
24+
```bash
25+
npm test -- --grep "MatchInput"
26+
```
27+
28+
Tests live in `src/test/suite/**/*.test.ts`, compile to `out/test/suite/**/*.test.js`, and run inside a real Extension Host against the workspace `test/ws_unittests/`. Mocha TDD UI, 20s default timeout (`.vscode-test.mjs`). `src/test/direct/` contains plain-node debug scripts, not part of the suite.
29+
30+
Launch configs (`.vscode/launch.json`):
31+
- **Run Extension** — opens Extension Development Host on `test/ws_manual/` (default F5)
32+
- **Run Extension without Workspace** — uses `test/ws_empty/`
33+
- **Extension Tests** — runs the suite with `watch-tests` as pre-launch
34+
35+
CI (`.github/workflows/ci.yml`) runs lint → compile → compile-tests → `xvfb-run npm test` on push to `main`/`master`/`develop` and on PRs.
36+
37+
## Architecture
38+
39+
Entry: `src/extension.ts``Startup(config).run(context)` (in `src/ext/startup.ts`) which initializes the `Ctrl` service locator and registers commands, code actions, and optional syntax highlighting.
40+
41+
**Service locator pattern.** `Ctrl` (`src/util/controller.ts`) owns one instance each of `Configuration`, `Parser`, `Writer`, `Reader`, `Inject`, `Dialogues`, and `Logger`. Every command/provider receives `Ctrl` in its constructor and reaches services through it. PLAN.md Phase 2.1 marks this for replacement with proper DI — new code should be written so it can accept narrower interfaces later, not lean harder on `Ctrl`.
42+
43+
**Namespace barrel imports.** `src/index.ts` re-exports submodules as `J.Extension`, `J.Actions`, `J.Model`, `J.Util`, `J.Provider`. Existing code does `import * as J from '..'` and references `J.Util.Ctrl`, `J.Actions.Writer`, etc. PLAN.md Phase 2.3 marks this for replacement with named imports — prefer named imports in new files.
44+
45+
**Module responsibilities** (need multiple files to grasp):
46+
47+
- `src/ext/` — VS Code surface integration. `Configuration` (`conf.ts`) reads `journal.*` settings and resolves templates/scopes. `Dialogues` drives QuickPick/InputBox. `Startup` wires everything. i18n uses `vscode.l10n` — manifest strings in `package.nls*.json` at the repo root, runtime strings in `l10n/bundle.l10n*.json` (regenerated via `npm run l10n:export`).
48+
- `src/actions/` — Core domain logic, no direct command bindings.
49+
- `Parser` — turns user input/URIs into structured `Input` (date, note, memo, task, weekly).
50+
- `Reader` — loads entries/notes from the configured base directory using `vscode.workspace.fs`.
51+
- `Writer` — creates new files (entry, note, weekly) and opens text documents.
52+
- `Inject` — modifies existing documents (insert memo/task/file link, shift task).
53+
- `src/model/` — Plain data types: `Input`, `FileEntry`, `HeaderTemplate`/`InlineTemplate`/`ScopedTemplate`, scope/quickpick types.
54+
- `src/provider/` — VS Code-facing surface.
55+
- `commands/` — one file per registered command (`journal.today`, `journal.note`, `journal.printDuration`, etc.); each exports a static `create(ctrl)` that returns the `Disposable`.
56+
- `codeactions/` — markdown code actions for completed and open task lines.
57+
- `codelens/` — task migration/shift CodeLens providers (not all registered yet — see `Startup.registerCodeLens`).
58+
- `features/` — reusable building blocks: `MatchInput` (smart-input resolver), `ScanEntries` (directory walker + cache for QuickPick), `LoadNotes`, `SyncNoteLinks`.
59+
- `src/util/``Ctrl`, `Logger` (OutputChannel-backed), `dates.ts` (moment-based, slated for removal in Phase 3), `paths.ts`, `strings.ts`.
60+
61+
**Smart-input flow.** User triggers `journal.day` (`Ctrl+Shift+J`) → `Dialogues` shows InputBox → `MatchInput.parseInput()` classifies the text (date expression, weekday, "memo:", "task:", "note ...", week reference) → command dispatches to `Reader`/`Writer`/`Inject`. The default path/file patterns (`${base}/${year}/${month}/${day}` for notes, `${base}/${year}/${month}/${day}.${ext}` for entries) come from `journal.patterns` in `package.json`.
62+
63+
**Filesystem.** Always go through `vscode.workspace.fs` (the extension declares `extensionKind: ["workspace"]` so it runs on the remote host for Remote SSH/Codespaces). Avoid raw `fs` / `fs.promises` in new code — PLAN.md Phase 1.3 finished migrating the old `fs` call sites; do not reintroduce them.
64+
65+
**Templates.** All user-facing inserted content comes from `journal.templates` (array of `{name, template, after?}`). Lookup happens via `Configuration.getInlineTemplate(name, fallback)`. Default template names: `memo`, `task`, `entry`, `time`, `note`, `files`, `weekly`. Issue #167 was a name-mismatch bug (`week` vs `weekly`) — when adding a new template type, register the name consistently in `package.json` defaults and the consumer.
66+
67+
## Notes for changes
68+
69+
- `PLAN.md` is the active modernization roadmap. Phases 0 and 1 are complete; Phase 2+ is open. Match the direction in the plan (DI, named imports, native `async`/`await` instead of `new Promise()` wrappers, `vscode.workspace.fs`, replacing moment with `Intl`/`date-fns`).
70+
- ESLint flat config (`eslint.config.mjs`) enforces `curly`, `eqeqeq`, `no-throw-literal`, `semi`. Import naming must be `camelCase` or `PascalCase`.
71+
- `tsconfig.json` runs `strict`, `noImplicitReturns`, `noFallthroughCasesInSwitch`. The bundle goes through esbuild, but tests are compiled via `tsc` — both must succeed for `npm test`.
72+
- `docs/` contains user-facing feature docs (entries, notes, memos, tasks, scopes, settings, codeactions) and `docs/analysis/` holds the analysis that produced `PLAN.md`.

PLAN.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@
3434
## Phase 1: Critical Bug Fixes
3535

3636
### 1.1 — Fix #167: Weekly Template Name Mismatch
37-
- [ ] `conf.ts:getWeeklyTemplate()` calls `getInlineTemplate("week", ...)` but `package.json` default template is named `"weekly"`
38-
- [ ] **Fix**: Change lookup key to `"weekly"` OR change default template name to `"week"` (the latter matches the method name and is cleaner)
39-
- [ ] Add regression test
37+
- [x] `conf.ts:getWeeklyTemplate()` calls `getInlineTemplate("week", ...)` but `package.json` default template is named `"weekly"`
38+
- [x] **Fix**: Changed lookup key to `"weekly"` to match the default template name in `package.json`
39+
- [x] Add regression test
4040

4141
### 1.2 — Fix #170: Wrong Day Set on New Entry
42-
- [ ] `MatchInput` stores `this.today = new Date()` at construction time; if the instance is reused across midnight, dates are wrong
43-
- [ ] **Fix**: Compute `today` at parse time, not construction time
44-
- [ ] Review `resolveISOString()`, `resolveWeekday()`, `resolveDayOfMonth()` for off-by-one errors
45-
- [ ] Add unit tests for edge cases (midnight boundary, timezone transitions)
42+
- [x] `MatchInput` stores `this.today = new Date()` at construction time; if the instance is reused across midnight, dates are wrong
43+
- [x] **Fix**: Added `refreshToday()` called at start of every `parseInput()`. Removed unused stale `Parser.today` field.
44+
- [x] Review `resolveISOString()`, `resolveWeekday()`, `resolveDayOfMonth()` for off-by-one errors — fixed month validation (`>12``>11`) and day validation (`<0``<1`)
45+
- [x] Add unit tests for edge cases (midnight boundary, timezone transitions)
4646

4747
### 1.3 — Fix #94: Remote Workspace Support (Local VS Remote Hosting)
48-
- [ ] Add `"extensionKind": ["workspace"]` to `package.json` so the extension runs on the remote host
49-
- [ ] Replace all direct `fs` calls with `vscode.workspace.fs` API:
50-
- `util/paths.ts``checkIfFileIsAccessible()` → use `vscode.workspace.fs.stat()`
51-
- `provider/features/scan-entries.ts``walkDir()` / `walkDirSync()` → use `vscode.workspace.fs.readDirectory()`
52-
- `provider/features/sync-note-links.ts``getFilesInNotesFolder()` use `vscode.workspace.fs.readDirectory()` + `vscode.workspace.fs.stat()`
53-
- `ext/startup.ts``fs.promises.readFile()` for color config → bundle color configs or use `vscode.workspace.fs`
54-
- [ ] Replace `os.homedir()` usage in `conf.ts` with platform-appropriate handling:
55-
- In remote context, use `vscode.Uri.joinPath(context.globalStorageUri, ...)` or let user configure explicitly
56-
- Provide sensible fallback when `os.homedir()` returns the local home in a remote session
57-
- [ ] Replace `untitled:` URI scheme in `writer.ts:createSaveLoadTextDocument()` with `vscode.workspace.fs.writeFile()` + `vscode.workspace.openTextDocument()`
58-
- [ ] Add integration test verifying file creation via `vscode.workspace.fs`
48+
Make sure that, when running on a remote host, the extension can still access the journal files on the local file system. Validate if the following plan supports this.
49+
50+
- [x] Add `"extensionKind": ["workspace"]` to `package.json` so the extension runs on the remote host
51+
- [x] Replace all direct `fs` calls with `vscode.workspace.fs` API:
52+
- `util/paths.ts``checkIfFileIsAccessible()``vscode.workspace.fs.stat()`
53+
- `provider/features/scan-entries.ts``walkDir()` / `walkDirSync()``vscode.workspace.fs.readDirectory()` + `stat()`
54+
- `provider/features/sync-note-links.ts``getFilesInNotesFolder()` `vscode.workspace.fs.readDirectory()` + `stat()`
55+
- `ext/startup.ts``fs.promises.readFile()``vscode.workspace.fs.readFile()`
56+
- [x] `os.homedir()` in `conf.ts`: No change needed — with `extensionKind: ["workspace"]` the extension runs on the remote host, so `os.homedir()` correctly returns the remote home directory where the journal resides
57+
- [x] Replace `untitled:` URI scheme in `writer.ts:createSaveLoadTextDocument()` with `vscode.workspace.fs.writeFile()` + `vscode.workspace.openTextDocument()`
58+
- [x] Add integration test verifying file creation via `vscode.workspace.fs`
5959

6060
---
6161

@@ -88,9 +88,9 @@
8888
- [ ] Example: `import { Ctrl } from '../util/controller'` instead of `J.Util.Ctrl`
8989

9090
### 2.4 — Modernize Activation
91-
- [ ] Remove explicit `activationEvents` from `package.json` (VS Code 1.74+ supports implicit activation from `contributes.commands`)
91+
- [x] Remove explicit `activationEvents` from `package.json` (VS Code 1.74+ supports implicit activation from `contributes.commands`)
9292
- [ ] Or replace with `"onStartupFinished"` if the extension needs early initialization
93-
- [ ] Remove the `journal.test` command and its activation event
93+
- [x] Remove the `journal.test` command and its activation event
9494

9595
### 2.5 — Fix Syntax Highlighting Approach
9696
- [ ] Remove `enableSyntaxHighlighting()` / `disableSyntaxHighlighting()` that modify global user settings
@@ -171,13 +171,13 @@
171171
- [ ] Remove `getPreviouslyAccessedFilesSync()` in `scan-entries.ts` (not used)
172172
- [ ] Remove `JournalCodeLensProvider` in `vscode-codelens.ts` (disabled since 0.12, uses placeholder command)
173173
- [ ] Remove the `InsertMemoCommand` if it's truly identical to `ShowEntryForInputCommand` (or merge)
174-
- [ ] Remove `@vscode/extension-telemetry` if not actually used
174+
- [x] Remove `@vscode/extension-telemetry` if not actually used
175175
- [ ] Clean up `show-pick-list.ts` (219 bytes, likely empty/stub)
176176

177177
### 5.4 — Improve i18n
178-
- [ ] Replace hardcoded locale strings in `getInputDetailsTimeFormat()` with translations from `messages.json`
179-
- [ ] Add support for VS Code's built-in `vscode.l10n` API (available since 1.73) instead of custom translation system
180-
- [ ] Move all user-facing strings to the l10n system
178+
- [ ] Replace hardcoded locale strings in `getInputDetailsTimeFormat()` (still hardcoded in `src/ext/conf.ts`)
179+
- [x] Add support for VS Code's built-in `vscode.l10n` API (available since 1.73) instead of custom translation system
180+
- [x] Move all QuickPick/InputBox user-facing strings to the l10n system (`getInputDetailsTimeFormat()` hardcoded strings remain — tied to moment removal in Phase 3)
181181

182182
---
183183

0 commit comments

Comments
 (0)