summd 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js CHANGED
@@ -26,8 +26,11 @@ function text(result) {
26
26
  return result.content.map(c => c.text).join('');
27
27
  }
28
28
  // ── Public API ────────────────────────────────────────────────────────────────
29
- export async function add(content, tags, opts) {
30
- return text(await tool('add_entry', { content, tags }, opts));
29
+ export async function add(content, tags, opts, note) {
30
+ const args = { content, tags, source_type: 'cli' };
31
+ if (note)
32
+ args.note = note;
33
+ return text(await tool('add_entry', args, opts));
31
34
  }
32
35
  export async function search(query, limit, opts) {
33
36
  return text(await tool('search_context', { query, limit }, opts));
package/dist/index.js CHANGED
@@ -1,9 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from 'fs';
3
+ import { extname } from 'path';
3
4
  import { createInterface } from 'readline';
4
5
  import { program } from 'commander';
5
6
  import { saveKey } from './config.js';
6
7
  import * as api from './api.js';
8
+ const CODE_EXTS = new Set([
9
+ 'js', 'ts', 'jsx', 'tsx', 'mjs', 'cjs',
10
+ 'py', 'rb', 'go', 'rs', 'java', 'kt', 'swift', 'c', 'cpp', 'cs',
11
+ 'sh', 'bash', 'zsh', 'fish',
12
+ 'json', 'yaml', 'yml', 'toml', 'xml',
13
+ 'sql', 'graphql', 'html', 'css', 'scss',
14
+ ]);
15
+ function wrapIfCode(content, filePath) {
16
+ const ext = extname(filePath).slice(1).toLowerCase();
17
+ if (!CODE_EXTS.has(ext))
18
+ return content;
19
+ return `\`\`\`${ext}\n${content}\n\`\`\``;
20
+ }
7
21
  // ── helpers ───────────────────────────────────────────────────────────────────
8
22
  function globalOpts() {
9
23
  return program.opts();
@@ -32,7 +46,7 @@ function formatDate(iso) {
32
46
  program
33
47
  .name('summd')
34
48
  .description('Sum to anything.')
35
- .version('0.1.2')
49
+ .version('0.1.3')
36
50
  .option('--key <token>', 'API key for this request')
37
51
  .option('--base <url>', 'Override API base URL');
38
52
  // ── summd key ─────────────────────────────────────────────────────────────────
@@ -49,18 +63,21 @@ program
49
63
  .description('Add an entry — reads stdin if no content given')
50
64
  .option('-t, --tag <tags>', 'Comma-separated tags')
51
65
  .option('-f, --file <path>', 'Read content from file')
66
+ .option('-n, --note <text>', 'Personal annotation (not included in AI summarization)')
52
67
  .action(async (content, cmd) => {
53
68
  const tags = cmd.tag ? cmd.tag.split(',').map(t => t.trim()) : [];
54
69
  let body = content;
55
- if (!body && cmd.file)
56
- body = readFileSync(cmd.file, 'utf8');
70
+ if (!body && cmd.file) {
71
+ const raw = readFileSync(cmd.file, 'utf8');
72
+ body = wrapIfCode(raw, cmd.file);
73
+ }
57
74
  if (!body && !process.stdin.isTTY)
58
75
  body = await readStdin();
59
76
  if (!body) {
60
77
  console.error('Provide content, --file, or pipe from stdin.');
61
78
  process.exit(1);
62
79
  }
63
- console.log(await api.add(body, tags, globalOpts()));
80
+ console.log(await api.add(body, tags, globalOpts(), cmd.note));
64
81
  });
65
82
  // ── summd search ──────────────────────────────────────────────────────────────
66
83
  program
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "summd",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for sum.md — Sum to anything.",
5
5
  "license": "MIT",
6
- "bin": { "summd": "./dist/index.js" },
6
+ "bin": {
7
+ "summd": "./dist/index.js"
8
+ },
7
9
  "type": "module",
8
- "files": ["dist", "README.md"],
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
9
14
  "scripts": {
10
15
  "build": "tsc",
11
16
  "dev": "tsc --watch",
@@ -18,5 +23,7 @@
18
23
  "@types/node": "^20.0.0",
19
24
  "typescript": "^5.0.0"
20
25
  },
21
- "engines": { "node": ">=18" }
26
+ "engines": {
27
+ "node": ">=18"
28
+ }
22
29
  }