Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
65 changes: 65 additions & 0 deletions .ai/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Architecture

## Product boundary

IT Tools is a client-only Vue 3 SPA/PWA. Tool input stays in the browser. The
production artifact is static `dist/` content served by nginx; there is no
application server, account system, cloud sync, or runtime API dependency for
the local catalog. Network-aware tools must disclose and strictly bound any
request they make.

## Source layout

- `src/tools/<tool>/` owns one routed tool. Its `index.ts` contains typed
registry metadata, the public route, its individual icon, and a lazy Vue
component import.
- `scripts/generate-tool-registry.mjs` statically generates `src/tools/index.ts`.
It preserves individual tool icons without eagerly importing tool modules.
- `src/ui/` contains low-level `c-*` controls; `src/components/` contains shared
application patterns; `src/utils/` and `src/composable/` contain browser and
transformation infrastructure.
- `src/modules/pwa/` owns production registration and development cleanup.
- `.ai/baselines/build-budgets.json` is the executable artifact budget policy.

## Runtime contracts

All route components stay lazy. Heavy parsers, datasets, editors, crypto, and
workers stay route-owned and demand-loaded. Large or attacker-controlled work
uses explicit actions or bounded debounce, input/output limits, timeout,
cancellation, stale-result protection, and disposal on route teardown.

The common worker lifecycle is implemented by `src/utils/worker-protocol.ts`,
`src/utils/worker-task.ts`, and `src/utils/bounded-text-task.ts`. Workers validate
both request and response envelopes; replacement, cancellation, timeout, and
unmount terminate the physical worker.

Production caches the shell and demand-caches opened lazy assets. Development
does not register a service worker and removes only IT Tools-owned stale PWA
state. Storage and privacy rules are in `PERSISTENCE.md`.

## Delivery

The supported toolchain is Node 24, pnpm 9.11.0, Vite, Vitest, Playwright, and
Docker/nginx. CI uses the frozen lockfile, builds the static artifact, enforces
budgets, runs browser smoke, audits production dependencies, scans the runtime
image, and checks root plus reverse-proxy/subpath delivery.

`pnpm build:standalone` is a separate delivery mode. It generates a 126-tool
registry, emits an AMD route graph, embeds JavaScript, CSS, worker programs,
icons, and figlet fonts, then writes only `dist-standalone/it-tools.html`.
The HTML bootstraps from an inline gzip payload and uses a main-thread worker
compatibility layer because the target DataLens CSP sets `worker-src 'none'`.
Standalone uses hash routing, skips PWA registration, keeps menu collapse state
in memory, and sends downloads and external links to the parent through
`EXPORT` and `OPEN_URL` messages. None of these choices affect the normal
`dist/` build.

Standalone worker compatibility is executable policy: the CSP sandbox test
runs a valid operation through all 48 included worker clients in Chromium,
Firefox, and WebKit, while a source-inventory test requires exact case coverage.
The emulated scope owns receiver-sensitive Web APIs and the packager classifies
only `*.worker-<hash>.js` as worker programs; `*.worker-client-<hash>.js` remains
part of the AMD lazy module graph.

The local fork is authoritative. Upstream material is research only and must
not be merged or adapted without an explicit approved record in `TODO.md`.
26 changes: 26 additions & 0 deletions .ai/FEATURES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Feature State

The approved browser-only catalog is implemented. The generated registry
currently contains 133 lazy tools across Crypto, Converter, Web, Images and
videos, Development, Network, Math, Measurement, Text, and Data.

The catalog includes the final approved additions: local mock data, IPv6/CIDR,
two-way Docker command conversion, masking/HAR sanitization, timezone/duration,
cron schedules, barcode workflows, JWK/JWKS and asymmetric JWT verification,
OpenAPI inspection, PKCS#12/public PEM inspection, offline GeoIP, and the local
encrypted OTP vault.

The definitive inventory is generated from `src/tools/*/index.ts`; do not keep
a second hand-maintained list here. Every tool keeps its own icon and lazy route
component.

The optional single-file build contains 126 tools. Its reviewed exclusions are
Camera Recorder, DNS over HTTPS Query, Local Encrypted OTP Vault, Mermaid
Diagram, Offline GeoIP Inspector, PDF Signature Checker, and Text Diff. The
reasons are sandbox permissions/network policy, unavailable opaque-origin
storage, or the strict 10 MiB artifact budget. These tools remain present in
the normal 133-tool application.

No new feature backlog is approved. Server-dependent products, account/cloud
features, network scanning, remote GeoIP/API services, heavy OCR/PDF workspaces,
and broad converter/obfuscation expansion are outside the product boundary.
24 changes: 24 additions & 0 deletions .ai/FIXES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Resolved Engineering State

The approved correctness, security, delivery, persistence, and performance
work is complete as of 2026-08-16.

- Production dependency audit has no known advisory in the approved graph.
- Crypto, YAML, i18n, Ajv, forge/PKI, nginx, and container concerns were fixed or
replaced with bounded browser-local implementations and executable gates.
- Registry generation keeps routes lazy and preserves each tool's individual
icon; category-wide icon substitution is explicitly a regression.
- Large transforms and sensitive operations have bounded worker lifecycles.
- Root, subpath, reverse-proxy, security-header, PWA, Firefox, WebKit, Chromium,
and Long Task coverage exists in the repository.
- Storage migrations, quota failure, rollback, and stale-cache cleanup are
tested; sensitive content is not persisted by default.
- The DataLens standalone sandbox renders explicit router-link menu items with
unique SVG icons, never touches opaque-origin storage, and executes embedded
worker programs without violating `worker-src 'none'`. All 48 included worker
clients now have an inventory-checked core-operation smoke in Chromium,
Firefox, and WebKit.

Do not resurrect historical upstream issue/PR dumps as a backlog. Reproduce a
new defect locally, add a failing regression test, and record only unresolved
work in `TODO.md`.
90 changes: 90 additions & 0 deletions .ai/HANDOFF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Current Handoff

## State

The final approved product package is implemented. There is no remaining
feature plan. The application is a browser-only static SPA/PWA with 133 lazy
tool routes, generated from per-tool typed metadata. Unique tool icons are a
product requirement and are preserved by the registry generator.

The repository may be intentionally dirty; inspect `git status` and never
overwrite unrelated local-fork work. Do not merge, rebase, or cherry-pick
upstream automatically.

Current checkpoint: branch `feat-ai-research`, base commit
`2530780ffb46bd309172aa21ff38d0881cd45cd1`. The 2026-08-24 standalone worker
compatibility audit is present as uncommitted local work at handoff time; keep
the whole worktree together when committing or transferring it.

## Resume

```sh
corepack enable
pnpm install --frozen-lockfile
git status --short
node scripts/generate-tool-registry.mjs --check
pnpm lint
pnpm typecheck
pnpm exec vitest run --environment jsdom
pnpm build
pnpm build:stats:check
pnpm build:standalone
pnpm test:standalone
```

Use one-shot Vitest; `pnpm test:unit` is currently also one-shot but the explicit
command is unambiguous. Run browser/container/security checks in proportion to
the touched surface.

## Standalone/DataLens

The final artifact is `dist-standalone/it-tools.html`: one 7,989,122-byte file
(7.62 MiB; 7,991,173-byte JSON upload envelope) with 126 tools and no runtime
network resources. `pnpm test:standalone` rebuilds it from current sources and
runs Chromium, Firefox, and WebKit serially.

The DataLens regression test reproduces the supplied HTTPS iframe with
`sandbox="allow-scripts"`, opaque origin, COOP, the injected CSP including
`connect-src 'none'` and `worker-src 'none'`, and disabled downloads. It checks
all 126 menu labels, their SVG icons, denied `localStorage`, `EXPORT`,
`OPEN_URL`, and an empty runtime/network error set. It also runs one valid core
operation through every one of the 48 included worker clients. A source
inventory test fails when an included worker client has no audit case.

The worker compatibility layer must keep Vite worker assets distinct from lazy
chunks whose names contain `.worker-client-`, and it must expose host Web APIs
such as `crypto`, `atob`, and `btoa` as own receiver-safe properties of the
emulated worker scope. These are regression fixes, not optional optimizations.

Do not switch the standalone sidebar back to Naive UI `NMenu`: its AMD render
produced empty `n-menu-item` elements in the real sandbox. The standalone-only
plain router-link menu is intentional; the normal application still uses
`NMenu`. Do not add intermediate-reuse flags to the build—the fresh build and
unconditional cleanup are part of the stale-cache defense.

Green gates for the 2026-08-24 audit: `pnpm test:standalone` (4 Node tests and
6 Playwright tests; 48/48 worker operations in Chromium, Firefox, and WebKit),
`pnpm lint`, `pnpm test:unit` (262 files / 1,466 tests), and `pnpm build`.
The final normal build restored full generated component declarations, including
the camera-specific icons excluded only from standalone.

## Invariants

- Inputs remain local and ephemeral unless a narrow feature explicitly says
otherwise.
- Tool components, heavy dependencies, datasets, and workers remain lazy.
- Tool metadata lives in `src/tools/<tool>/index.ts`; regenerate, never manually
edit `src/tools/index.ts`.
- Each tool retains its own icon. Do not replace tool icons with category icons.
- Worker tasks validate envelopes and enforce limits, timeout, cancellation,
stale-result protection, and physical disposal.
- PWA installs the shell and demand-caches opened lazy assets.
- UI transformers are wide and vertical unless they are actual diff tools.
- `.ai/baselines/build-budgets.json` is executable policy, not historical prose.

## Browser review

Use the existing Orca embedded browser via the `orca-cli` skill and the exact
procedure in `ORCA_BROWSER.md`. Current-source review uses strict
`http://127.0.0.1:8091`; preview uses a freshly built `dist/` at port 5050. Do
not confuse the two or silently switch browser surfaces.
51 changes: 51 additions & 0 deletions .ai/ORCA_BROWSER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Orca Browser Runbook

Use the `orca-cli` skill for Orca's embedded browser. Reuse the user's existing
tab, obtain its `browserPageId` with `orca tab list --json`, and pass `--page`
when the active page is ambiguous. Do not substitute the generic browser
connector. Computer Use is only for browser windows or Orca chrome outside the
embedded page.

## Current-source server

Run `pnpm dev` in a dedicated non-agent Orca terminal. It serves strict
`http://127.0.0.1:8091` with `Cache-Control: no-store` and
`X-IT-Tools-Mode: development`. Use `pnpm dev:fresh` only when Vite's optimized
dependency cache is suspect. It adds `--force`; it does not read `dist/`.

Production review requires `pnpm build && pnpm preview` and uses strict
`http://127.0.0.1:5050`. Preview serves `dist/`; never use it as evidence for
current source without a fresh build. `localhost` and `127.0.0.1` are different
origins with independent caches and service workers.

## Navigation and stale-cache diagnosis

```sh
orca goto --url http://127.0.0.1:8091/ --json
orca wait --load networkidle --json
orca snapshot --json
```

Dev must load `/@vite/client` and `/src/main.ts`, expose the development header,
and have no service-worker controller. Hashed `/assets/index-*.js` or a Workbox
controller means the tab is showing a production artifact.

Inspect before clearing:

```sh
orca eval --expression "(async()=>({href:location.href,controller:navigator.serviceWorker.controller?.scriptURL||null,registrations:(await navigator.serviceWorker.getRegistrations()).map(r=>({scope:r.scope,active:r.active?.scriptURL})),caches:await caches.keys(),scripts:[...document.scripts].map(s=>s.src).filter(Boolean)}))()" --json
```

If stale IT Tools state blocks dev, unregister only the root registration whose
worker pathname is `/sw.js`; delete only caches prefixed with
`workbox-precache-`, `it-tools-lazy-assets-`, or `figlet-fonts-`; then reload.
Never clear all browser data, storage, unrelated caches, or other origins. The
source-dev runtime performs this narrow cleanup automatically when it can load.

Use snapshot, semantic interaction, and a new snapshot for review. Element
references expire after navigation or DOM changes. Verify computed styles and
accessible state in addition to screenshots.

If Orca reports `runtime_unavailable` after one status/open retry, stop guessing
alternate surfaces. Keep manual acceptance open and run `pnpm test:dev-runtime`
against the verified 8091 server; report the Orca runtime failure explicitly.
52 changes: 52 additions & 0 deletions .ai/PERFORMANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Performance Contract

## Current baseline

The generated registry contains 133 lazy routes. The accepted normal build on
2026-08-17 measured a 687,421-byte raw / 186,417-byte gzip main entry, a
716,733-byte raw / 192,710-byte gzip shell including the document, and a
53-file, 970,294-byte raw / 313,252-byte gzip Workbox payload. All 426 build
budget checks passed with unique tool icons preserved.

The accepted standalone artifact contains 126 tools in one HTML file. It is
7,989,122 bytes (7.62 MiB); the JSON upload envelope `{ "html": ... }` is
7,991,173 bytes. Both are below the strict 10 MiB limit. The build fails if
either measurement exceeds that limit and always removes its intermediate
directory to prevent stale-build reuse. The increase records the exhaustive
standalone-only 48-client compatibility audit and its small XLSX fixture; it
does not enter the normal application build.

Production large-result fixtures for SQL, JSON-to-CSV, JSON Minify, and List
Converter publish bounded previews while Copy/Blob download retains the full
bounded result. The accepted runs observed no Long Task at or above 50 ms.
Emoji search is worker-backed and virtualized. Monaco remains accepted for Text
Diff: the smaller CodeMirror spike lost focus, undo, and history when publishing
async diff results.

## Gates

`.ai/baselines/build-budgets.json` is the sole detailed budget source. It
enforces shell and Workbox totals, a 500 kB default dynamic-entry ceiling, and
narrow rationale-backed exceptions for unavoidable route-owned assets. Generate
fresh measurements with:

```sh
pnpm build
pnpm build:stats
pnpm build:stats:check
pnpm build:standalone
pnpm test:standalone
```

Never update a budget merely to make a failure pass. Record the before/after
raw and gzip sizes, cold-route/result-ready timing, longest observed task, and
PWA impact. New shell work must keep parsers, datasets, tool components, and
heavy editors out of the initial graph.

## Responsiveness rules

- Do not synchronously parse or transform large input on every keystroke.
- Use explicit action above the tool's documented live threshold.
- Bound input, output, amplification, time, messages, and worker lifecycle.
- Show a bounded DOM preview for large results; copy/download the full result.
- Dispose workers, editors, media, observers, timers, and object URLs.
21 changes: 21 additions & 0 deletions .ai/PERSISTENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Persistence and Privacy

Tool content is potentially secret and ephemeral by default. Passwords,
tokens, OTP secrets, private keys, JWTs, certificates, documents, diffs, and
pasted configuration must not enter general local persistence, logs, analytics,
CDNs, or third-party services.

Harmless preferences use namespaced, versioned, size-bounded storage. Approved
content persistence must be opt-in, documented, clearable, and resilient to
migration, quota, parse, write, and rollback failures. Large state belongs in
IndexedDB rather than synchronous per-keystroke `localStorage`.

The Local Encrypted OTP Vault is the deliberate exception: encrypted records
live in IndexedDB, keys are derived/unwrapped with Web Crypto, plaintext stays
in memory only while unlocked, and there are no accounts or synchronization.
Locking, timeout, close, migration failure, or cryptographic failure clears
decrypted state.

Development PWA cleanup may unregister only the root IT Tools `sw.js` and delete
only `workbox-precache-*`, `it-tools-lazy-assets-*`, and `figlet-fonts-*`. It
must not clear local/session content or unrelated origins/caches.
27 changes: 27 additions & 0 deletions .ai/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Approved Work

There is no remaining approved feature backlog. Do not invent additional tools
or revive removed upstream lists.

Future work begins only from an explicit user request or a locally reproduced
regression. Before implementation, record the narrow scope here, including any
intentional upstream adaptation that requires approval.

## Maintenance definition of done

```sh
pnpm lint
pnpm typecheck
pnpm exec vitest run --environment jsdom
pnpm build
pnpm build:stats:check
pnpm test:e2e --project=chromium --reporter=line
```

Run Firefox/WebKit, container, subpath, security, and focused performance gates
when the change touches those surfaces. Keep routes lazy, unique tool icons,
privacy defaults, worker limits/cancellation, and build budgets intact.

## Upstream adaptations

None are currently approved or pending.
34 changes: 34 additions & 0 deletions .ai/UI_CONSISTENCY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# UI Contract

All tools use the existing `c-*` controls and UnoCSS tokens. Tool-specific
visual identity is intentional: each route keeps its unique icon. Form geometry,
state, and interaction semantics are shared.

## Layout

- Transformation editors stack vertically unless the tool is explicitly a
diff/comparison view. Input and output use the same available width and
comparable heights.
- Large desktop utilities use the content width; do not squeeze primary editors
into narrow form columns. Compact widths are reserved for short options.
- Related generators such as UUID, ULID, and NanoID follow the NanoID-style
hierarchy: options, primary action, then full-width result actions.
- Mobile stacks controls naturally without horizontal scrolling.

## Controls

- Reuse one label/help/error contract, checkbox/radio styling, field height,
focus ring, disabled state, and action hierarchy.
- Primary actions are explicit for expensive work. Copy/download operate on the
latest successful result and do not erase it on validation errors.
- Destructive actions are visually distinct and keyboard accessible.
- Empty, loading, error, success, and oversized-input states must not change the
page geometry unexpectedly.

## Acceptance

Representative light/dark and desktop/mobile states, keyboard focus, accessible
names, and visual snapshots are required for shared-control changes. Docker
Run/Compose and XML Formatter remain reference routes for the vertical wide
editor pattern; ID generators remain the reference family for generator
unification.
Loading
Loading