sumo-agents 0.0.0-stage → 0.3.0

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.
Files changed (66) hide show
  1. package/AGENTS.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +111 -2
  4. package/bin/sumo.mjs +33 -0
  5. package/guides/delegation.md +33 -0
  6. package/guides/feature.md +14 -0
  7. package/guides/fix.md +14 -0
  8. package/guides/memory.md +23 -0
  9. package/guides/projects.md +27 -0
  10. package/guides/review.md +16 -0
  11. package/guides/workflows.md +26 -0
  12. package/logo.txt +19 -0
  13. package/package.json +42 -4
  14. package/prompts/agent.md +7 -0
  15. package/prompts/dream.md +13 -0
  16. package/prompts/scribe.md +21 -0
  17. package/spinner.txt +90 -0
  18. package/src/advisor.mjs +59 -0
  19. package/src/apply.mjs +368 -0
  20. package/src/auth.mjs +80 -0
  21. package/src/card.mjs +72 -0
  22. package/src/catalog.mjs +167 -0
  23. package/src/chat.mjs +1162 -0
  24. package/src/cli.mjs +815 -0
  25. package/src/cost.mjs +128 -0
  26. package/src/db.mjs +384 -0
  27. package/src/dream.mjs +97 -0
  28. package/src/editor.mjs +198 -0
  29. package/src/export.mjs +132 -0
  30. package/src/guard.mjs +121 -0
  31. package/src/guides.mjs +86 -0
  32. package/src/herdr.mjs +117 -0
  33. package/src/hooks.mjs +270 -0
  34. package/src/images.mjs +89 -0
  35. package/src/jobs.mjs +1184 -0
  36. package/src/jobtools.mjs +82 -0
  37. package/src/local-server.mjs +169 -0
  38. package/src/lock.mjs +45 -0
  39. package/src/loop.mjs +838 -0
  40. package/src/mcp.mjs +604 -0
  41. package/src/memory.mjs +400 -0
  42. package/src/model.mjs +270 -0
  43. package/src/page.html +304 -0
  44. package/src/page.mjs +135 -0
  45. package/src/paths.mjs +33 -0
  46. package/src/prime.mjs +177 -0
  47. package/src/projects.mjs +232 -0
  48. package/src/recall.mjs +45 -0
  49. package/src/redact.mjs +173 -0
  50. package/src/render.mjs +45 -0
  51. package/src/route.mjs +287 -0
  52. package/src/sandbox.mjs +173 -0
  53. package/src/scan.mjs +204 -0
  54. package/src/scribe.mjs +349 -0
  55. package/src/sessions.mjs +371 -0
  56. package/src/setup.mjs +528 -0
  57. package/src/sqlite.mjs +66 -0
  58. package/src/text.mjs +97 -0
  59. package/src/tools.mjs +987 -0
  60. package/src/transcript.mjs +106 -0
  61. package/src/tty.mjs +529 -0
  62. package/src/ui.mjs +1363 -0
  63. package/src/verify.mjs +369 -0
  64. package/src/web.mjs +49 -0
  65. package/src/workflows.mjs +270 -0
  66. package/src/worktree.mjs +128 -0
package/src/text.mjs ADDED
@@ -0,0 +1,97 @@
1
+ export const STOPWORDS = new Set(
2
+ `a an and are as at be but by do does for from has have how i if in into is it its me my no not of
3
+ on or our so that the their them then there these this to us was we what when where which who why
4
+ will with you your`.split(/\s+/),
5
+ );
6
+
7
+ /** Lowercased content words of a text, in order, duplicates kept. */
8
+ export function words(text) {
9
+ const all = text.toLowerCase().match(/[\p{L}\p{N}_]+/gu) ?? [];
10
+ const kept = all.filter((w) => w.length >= 2 && !STOPWORDS.has(w));
11
+ // A query made only of stopwords still has to search for something.
12
+ return kept.length > 0 ? kept : all;
13
+ }
14
+
15
+ /**
16
+ * An FTS5 MATCH expression: every word quoted (so nothing the user types is
17
+ * read as query syntax) and OR-ed, leaving the ordering to BM25. AND is too
18
+ * strict for a question phrased in different words than the memory was.
19
+ */
20
+ export function ftsQuery(text) {
21
+ const unique = [...new Set(words(text))];
22
+ return unique.map((w) => `"${w.replaceAll('"', '""')}"`).join(' OR ');
23
+ }
24
+
25
+ /**
26
+ * Crude suffix stripping, for judging whether two short texts are about the
27
+ * same thing. The index itself uses SQLite's porter stemmer.
28
+ * The final "e" goes last, so "create", "creates", "created" and "creating" all meet at "creat".
29
+ */
30
+ export function stem(word) {
31
+ let out = word;
32
+ if (out.length > 5 && out.endsWith('ing')) out = out.slice(0, -3);
33
+ else if (out.length > 4 && out.endsWith('ed')) out = out.slice(0, -2);
34
+ else if (/(ss|x|z|ch|sh)es$/.test(out)) out = out.slice(0, -2); // classes, fixes, pushes — but not uses, cases
35
+ else if (out.length >= 3 && out.endsWith('s') && !out.endsWith('ss')) out = out.slice(0, -1); // PRs → pr
36
+ return out.length > 3 && out.endsWith('e') ? out.slice(0, -1) : out;
37
+ }
38
+
39
+ /** Share of the smaller text's stems also found in the other: 0..1. */
40
+ export function overlap(a, b) {
41
+ const sa = new Set(words(a).map(stem));
42
+ const sb = new Set(words(b).map(stem));
43
+ if (sa.size === 0 || sb.size === 0) return 0;
44
+ let shared = 0;
45
+ for (const s of sa) if (sb.has(s)) shared++;
46
+ return shared / Math.min(sa.size, sb.size);
47
+ }
48
+
49
+ /** How many distinct stems two texts have in common. */
50
+ export function sharedStems(a, b) {
51
+ const sb = new Set(words(b).map(stem));
52
+ return [...new Set(words(a).map(stem))].filter((s) => sb.has(s)).length;
53
+ }
54
+
55
+ /**
56
+ * Deliberately a heuristic: an exact count needs a tokenizer, and these numbers
57
+ * only have to keep a generated block under its budget.
58
+ */
59
+ export function estimateTokens(text) {
60
+ return Math.ceil(text.length / 4);
61
+ }
62
+
63
+ /** The first `max` units of a text, less half a character: a cut inside an emoji leaves a lone surrogate, which no API takes. */
64
+ /** How long something took or has run, for a line of the screen or of numbers: `42s`, `3m 05s`. */
65
+ export function elapsed(ms) {
66
+ const seconds = Math.floor(ms / 1000);
67
+ return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${String(seconds % 60).padStart(2, '0')}s`;
68
+ }
69
+
70
+ export function head(text, max) {
71
+ const cut = text.slice(0, max);
72
+ return /[\uD800-\uDBFF]$/.test(cut) ? cut.slice(0, -1) : cut;
73
+ }
74
+
75
+ export function clip(text, max) {
76
+ const flat = text.replace(/\s+/g, ' ').trim();
77
+ return flat.length <= max ? flat : `${head(flat, max - 1)}…`;
78
+ }
79
+
80
+ /** Words that mark a sentence as a standing instruction, which is worth filing right away rather than in the next batch. */
81
+ const DURABLE = /\b(always|never|from now on|going forward|remember|don'?t ever|i (prefer|like|want(?! to\b)|hate|use)|we (use|moved|switched|decided)|make sure|by default|every time|stop (doing|using))\b/i;
82
+
83
+ export const looksDurable = (text) => DURABLE.test(text);
84
+
85
+ /**
86
+ * A clause that asks for work or an answer — describe this, fix that, delegate, a question — rather than stating
87
+ * something. Only verbs that are almost never a standing rule: "write tests first" or "keep answers short" are rules.
88
+ * The words people open an order with (ok, lets, so) do not hide it, and "I want to …" is the next piece of work.
89
+ */
90
+ const OPENERS = /(?:(?:please|pls|now|then|also|and|so+|ok|okay|yes|yeah|yep|na+h|just|lets|let's|let\s+us)[\s,]+)*/.source;
91
+ const VERBS = /describe|explain|delegate|fix|find|investigate|look\s+(?:at|into|for)|show\s+me|tell\s+me|give\s+me|summari[sz]e|debug|continue|research|install|spawn|implement|proceed|resume|redeploy|restart|rerun|retry|go\s+ahead|carry\s+on|try\s+again|(?:can|could|would|will)\s+you|i\s+(?:want|need|would\s+like|'d\s+like)\s+to/.source;
92
+ /** What marks an order as one for now, whatever its verb: "not … yet" holds something for the moment, "let me know" asks for an answer. */
93
+ const FOR_NOW = /\b(?:not|n't|dont|don't)\b[^.!?\n]*\byet\b|\b(?:lmk|let\s+me\s+know)\b/.source;
94
+ const REQUEST = new RegExp(`(?:^|[.,:;!?)]\\s+|\\n\\s*)${OPENERS}(?:${VERBS})\\b|\\?\\s*$|${FOR_NOW}`, 'im');
95
+
96
+ /** Words that ask for work or an answer and state nothing that lasts: nothing in them is a memory. */
97
+ export const asksForWork = (text) => REQUEST.test(String(text ?? '')) && !looksDurable(String(text ?? ''));