Recently Written · git

ideamine

An idea inbox for Claude Code: /idea saves ideas at zero tokens; Claude triages them and routes each to the cheapest model that can build it.

git clone https://github.com/equwal/ideamine

Log | Files | Refs


tests/text.test.js (1689 bytes)

1 import assert from 'node:assert/strict';
2 import { test } from 'node:test';
3 import { deriveTitle, extractTags, isSimilar, splitIdeas, wordSet } from '../src/text.js';
4 
5 test('deriveTitle uses the first line, drops bullets and tags, and cuts at a word', () => {
6   assert.equal(deriveTitle('  Add dark mode #ui\nmore detail'), 'Add dark mode');
7   assert.equal(deriveTitle('- a bullet idea'), 'a bullet idea');
8   const long = 'Build a thing that does many things '.repeat(5);
9   const t = deriveTitle(long, 40);
10   assert.ok(t.length <= 40, t);
11   assert.ok(t.endsWith('…'));
12   assert.ok(!t.includes('  '));
13 });
14 
15 test('extractTags finds #words but not #numbers or C#', () => {
16   assert.deepEqual(extractTags('ship it #UI #perf-fix, see #12 and C# code'), ['ui', 'perf-fix']);
17 });
18 
19 test('splitIdeas splits a bulleted list and keeps continuation lines', () => {
20   assert.deepEqual(splitIdeas('- one\n- two\n  more about two\n* three'), ['one', 'two\nmore about two', 'three']);
21   assert.deepEqual(splitIdeas('1. first\n2) second'), ['first', 'second']);
22 });
23 
24 test('splitIdeas keeps prose (or a single bullet) as one idea', () => {
25   assert.deepEqual(splitIdeas('An idea\n- with a bullet inside'), ['An idea\n- with a bullet inside']);
26   assert.deepEqual(splitIdeas('- only one'), ['- only one']);
27   assert.deepEqual(splitIdeas('   '), []);
28 });
29 
30 test('isSimilar flags near-duplicates and not mere topic overlap', () => {
31   const a = wordSet('Add dark mode toggle to the popup');
32   assert.ok(isSimilar(a, wordSet('add a dark mode toggle in settings')));
33   assert.ok(!isSimilar(wordSet('fix login bug'), wordSet('fix signup bug')));
34   assert.ok(!isSimilar(a, wordSet('export ideas to notion')));
35 });