mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 21:27:01 +01:00
Audited the template against 514 real Claude sessions (1503 top-level prompts) joined to the 49 notes in BACKLOG.md. Sections were judged on whether the agent actually read them, not on fill rate — four of them said "leave blank if none" in their own helper, so a low fill rate was the section working correctly. Measured over the 22 note/session pairs: estimate filled 22, referenced 1 (4%) done filled 22, quoted back 4 (18%) refs filled 14, URLs fetched 5 (35%) tech the agent opened pubspec.yaml/CLAUDE.md anyway in 54% ask 100% ask rate with it, 92% without — no measurable effect Kept: title, what, where, must, done. Dropped: tech (into `where`), ask, nice and never (into `must` as `optional:` / `must not:` lines), depends, estimate. Renamed `refs` -> `read first`. Added `verify`, the only addition: "test it yourself, on the phone" was the single most repeated correction in the corpus, and 3 of the 7 filled `never` sections were already smuggling it in. Fixes a latent data-loss bug found while testing this. parse() treats an unknown `## heading` as content on purpose (values may contain subheadings), so a legacy `## tech` block was folded into the preceding section's value AND the note still reported conforming — opening any old note in the stepper would have swallowed it on the next save. NoteTemplate.retiredLabels now makes those notes explicitly non-conforming, so they open raw and untouched. tool/migrate_backlog.dart converts an old export (export -> migrate -> import). It is idempotent and gated: it throws if a rewritten note does not conform or if any source line vanishes. All 49 notes migrated on the desktop and merged to the phone (0 new, 25 updated, 24 unchanged). Also formats the few files dart format had never been run over, and extracts a local in frame_stats_io.dart so the reflowed line stays under 80 chars. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.8 KiB
Dart
44 lines
1.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
|
|
/// Resolves the home directory the desktop export writes under.
|
|
///
|
|
/// Overridable **so the test suite never writes to the real `~/todo`**. This is
|
|
/// not hypothetical: before this seam existed, running `flutter test` exported
|
|
/// a fake note over the user's canonical `~/todo/BACKLOG.md` every time.
|
|
String Function() resolveExportHome = () =>
|
|
Platform.environment['HOME'] ?? Directory.current.path;
|
|
|
|
/// Writes the Markdown export somewhere the user can get at it, and returns a
|
|
/// human-readable description of where it went.
|
|
///
|
|
/// On mobile this opens the system share sheet; on a `dart:io` desktop host it
|
|
/// writes the canonical `~/todo/BACKLOG.md`.
|
|
Future<String> exportBacklog(String markdown, int noteCount) async {
|
|
// coverage:ignore-start
|
|
// Mobile-only share path: Platform.isAndroid/isIOS are always false on the
|
|
// Linux test host, so these lines are structurally unreachable in CI and
|
|
// excluded from the coverage denominator. Verified on-device.
|
|
if (Platform.isAndroid || Platform.isIOS) {
|
|
final dir = await getTemporaryDirectory();
|
|
final file = File('${dir.path}/todo-backlog.md');
|
|
await file.writeAsString(markdown);
|
|
await SharePlus.instance.share(
|
|
ShareParams(
|
|
files: [XFile(file.path, mimeType: 'text/markdown')],
|
|
subject: 'todo backlog ($noteCount notes)',
|
|
),
|
|
);
|
|
return 'Shared $noteCount notes';
|
|
}
|
|
// coverage:ignore-end
|
|
final home = resolveExportHome();
|
|
final dir = Directory('$home/todo');
|
|
if (!dir.existsSync()) dir.createSync(recursive: true);
|
|
final file = File('${dir.path}/BACKLOG.md');
|
|
await file.writeAsString(markdown);
|
|
return 'Exported $noteCount notes to ${file.path}';
|
|
}
|