stagent 0.6.3 → 0.7.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 (123) hide show
  1. package/README.md +21 -2
  2. package/dist/cli.js +226 -1
  3. package/docs/.coverage-gaps.json +66 -16
  4. package/docs/.last-generated +1 -1
  5. package/docs/features/dashboard-kanban.md +13 -7
  6. package/docs/features/settings.md +15 -3
  7. package/docs/features/tables.md +122 -0
  8. package/docs/index.md +3 -2
  9. package/docs/journeys/developer.md +26 -16
  10. package/docs/journeys/personal-use.md +23 -9
  11. package/docs/journeys/power-user.md +40 -14
  12. package/docs/journeys/work-use.md +43 -15
  13. package/docs/manifest.json +27 -17
  14. package/package.json +3 -1
  15. package/src/app/api/chat/entities/search/route.ts +12 -3
  16. package/src/app/api/projects/[id]/route.ts +37 -0
  17. package/src/app/api/projects/__tests__/delete-project.test.ts +12 -0
  18. package/src/app/api/snapshots/[id]/restore/route.ts +62 -0
  19. package/src/app/api/snapshots/[id]/route.ts +44 -0
  20. package/src/app/api/snapshots/route.ts +54 -0
  21. package/src/app/api/snapshots/settings/route.ts +67 -0
  22. package/src/app/api/tables/[id]/charts/[chartId]/route.ts +89 -0
  23. package/src/app/api/tables/[id]/charts/route.ts +72 -0
  24. package/src/app/api/tables/[id]/columns/route.ts +70 -0
  25. package/src/app/api/tables/[id]/export/route.ts +94 -0
  26. package/src/app/api/tables/[id]/history/route.ts +15 -0
  27. package/src/app/api/tables/[id]/import/route.ts +111 -0
  28. package/src/app/api/tables/[id]/route.ts +86 -0
  29. package/src/app/api/tables/[id]/rows/[rowId]/history/route.ts +32 -0
  30. package/src/app/api/tables/[id]/rows/[rowId]/route.ts +51 -0
  31. package/src/app/api/tables/[id]/rows/route.ts +101 -0
  32. package/src/app/api/tables/[id]/triggers/[triggerId]/route.ts +65 -0
  33. package/src/app/api/tables/[id]/triggers/route.ts +122 -0
  34. package/src/app/api/tables/route.ts +65 -0
  35. package/src/app/api/tables/templates/route.ts +92 -0
  36. package/src/app/settings/page.tsx +2 -0
  37. package/src/app/tables/[id]/page.tsx +67 -0
  38. package/src/app/tables/page.tsx +21 -0
  39. package/src/app/tables/templates/page.tsx +19 -0
  40. package/src/components/chat/chat-table-result.tsx +139 -0
  41. package/src/components/documents/document-browser.tsx +1 -1
  42. package/src/components/projects/project-form-sheet.tsx +3 -27
  43. package/src/components/schedules/schedule-form.tsx +5 -27
  44. package/src/components/settings/data-management-section.tsx +17 -12
  45. package/src/components/settings/database-snapshots-section.tsx +469 -0
  46. package/src/components/shared/app-sidebar.tsx +2 -0
  47. package/src/components/shared/document-picker-sheet.tsx +214 -11
  48. package/src/components/tables/table-browser.tsx +234 -0
  49. package/src/components/tables/table-cell-editor.tsx +226 -0
  50. package/src/components/tables/table-chart-builder.tsx +288 -0
  51. package/src/components/tables/table-chart-view.tsx +146 -0
  52. package/src/components/tables/table-column-header.tsx +103 -0
  53. package/src/components/tables/table-column-sheet.tsx +331 -0
  54. package/src/components/tables/table-create-sheet.tsx +240 -0
  55. package/src/components/tables/table-detail-sheet.tsx +144 -0
  56. package/src/components/tables/table-detail-tabs.tsx +278 -0
  57. package/src/components/tables/table-grid.tsx +61 -0
  58. package/src/components/tables/table-history-tab.tsx +148 -0
  59. package/src/components/tables/table-import-wizard.tsx +542 -0
  60. package/src/components/tables/table-list-table.tsx +95 -0
  61. package/src/components/tables/table-relation-combobox.tsx +217 -0
  62. package/src/components/tables/table-spreadsheet.tsx +499 -0
  63. package/src/components/tables/table-template-gallery.tsx +162 -0
  64. package/src/components/tables/table-template-preview.tsx +219 -0
  65. package/src/components/tables/table-toolbar.tsx +79 -0
  66. package/src/components/tables/table-triggers-tab.tsx +446 -0
  67. package/src/components/tables/types.ts +6 -0
  68. package/src/components/tables/use-spreadsheet-keys.ts +171 -0
  69. package/src/components/tables/utils.ts +29 -0
  70. package/src/components/tasks/task-create-panel.tsx +5 -31
  71. package/src/components/tasks/task-edit-dialog.tsx +5 -27
  72. package/src/components/workflows/workflow-form-view.tsx +5 -29
  73. package/src/components/workflows/workflow-status-view.tsx +1 -1
  74. package/src/instrumentation.ts +3 -0
  75. package/src/lib/agents/__tests__/claude-agent.test.ts +5 -1
  76. package/src/lib/agents/claude-agent.ts +3 -1
  77. package/src/lib/agents/runtime/anthropic-direct.ts +29 -0
  78. package/src/lib/agents/runtime/openai-direct.ts +29 -0
  79. package/src/lib/chat/stagent-tools.ts +2 -0
  80. package/src/lib/chat/tool-catalog.ts +34 -0
  81. package/src/lib/chat/tools/table-tools.ts +955 -0
  82. package/src/lib/constants/table-status.ts +68 -0
  83. package/src/lib/data/__tests__/clear.test.ts +1 -1
  84. package/src/lib/data/clear.ts +45 -0
  85. package/src/lib/data/seed-data/__tests__/profiles.test.ts +28 -23
  86. package/src/lib/data/seed-data/conversations.ts +350 -42
  87. package/src/lib/data/seed-data/documents.ts +564 -591
  88. package/src/lib/data/seed-data/learned-context.ts +101 -22
  89. package/src/lib/data/seed-data/notifications.ts +344 -70
  90. package/src/lib/data/seed-data/profile-test-results.ts +92 -11
  91. package/src/lib/data/seed-data/profiles.ts +144 -46
  92. package/src/lib/data/seed-data/projects.ts +50 -18
  93. package/src/lib/data/seed-data/repo-imports.ts +28 -13
  94. package/src/lib/data/seed-data/schedules.ts +208 -41
  95. package/src/lib/data/seed-data/table-templates.ts +234 -0
  96. package/src/lib/data/seed-data/tasks.ts +614 -116
  97. package/src/lib/data/seed-data/usage-ledger.ts +182 -103
  98. package/src/lib/data/seed-data/user-tables.ts +203 -0
  99. package/src/lib/data/seed-data/views.ts +52 -7
  100. package/src/lib/data/seed-data/workflows.ts +231 -84
  101. package/src/lib/data/seed.ts +55 -14
  102. package/src/lib/data/tables.ts +417 -0
  103. package/src/lib/db/bootstrap.ts +227 -0
  104. package/src/lib/db/index.ts +9 -0
  105. package/src/lib/db/migrations/0019_add_tables_feature.sql +160 -0
  106. package/src/lib/db/migrations/0020_add_table_triggers.sql +19 -0
  107. package/src/lib/db/migrations/0021_add_row_history.sql +15 -0
  108. package/src/lib/db/schema.ts +368 -0
  109. package/src/lib/snapshots/auto-backup.ts +132 -0
  110. package/src/lib/snapshots/retention.ts +64 -0
  111. package/src/lib/snapshots/snapshot-manager.ts +429 -0
  112. package/src/lib/tables/computed.ts +61 -0
  113. package/src/lib/tables/context-builder.ts +139 -0
  114. package/src/lib/tables/formula-engine.ts +415 -0
  115. package/src/lib/tables/history.ts +115 -0
  116. package/src/lib/tables/import.ts +343 -0
  117. package/src/lib/tables/query-builder.ts +152 -0
  118. package/src/lib/tables/trigger-evaluator.ts +146 -0
  119. package/src/lib/tables/types.ts +141 -0
  120. package/src/lib/tables/validation.ts +119 -0
  121. package/src/lib/utils/stagent-paths.ts +20 -0
  122. package/tsconfig.json +3 -1
  123. /package/docs/features/{playbook.md → user-guide.md} +0 -0
@@ -19,74 +19,153 @@ export function createLearnedContext(
19
19
  const DAY = 86_400_000;
20
20
  const HOUR = 3_600_000;
21
21
 
22
- const sourceTask1 = completedTaskIds[0] ?? null;
23
- const sourceTask2 = completedTaskIds[1] ?? null;
22
+ const sourceTask2 = completedTaskIds[1] ?? null; // Copy variants (P1)
23
+ const sourceTask4 = completedTaskIds[3] ?? null; // Article (P2)
24
+ const sourceTask6 = completedTaskIds[5] ?? null; // Churn analysis (P3)
24
25
 
25
26
  return [
26
- // General profile: proposal → approved lifecycle
27
+ // GTM profile: proposal → approved (benefit-led headlines)
27
28
  {
28
29
  id: crypto.randomUUID(),
29
- profileId: "general",
30
+ profileId: "stagent-sample-gtm-launch-strategist",
30
31
  version: 1,
31
32
  content: null,
32
33
  diff: null,
33
34
  changeType: "proposal",
34
- sourceTaskId: sourceTask1,
35
+ sourceTaskId: sourceTask2,
35
36
  proposalNotificationId: null,
36
37
  proposedAdditions:
37
- "User prefers concise bullet-point summaries over paragraph-style output. When multiple options exist, present a ranked list with trade-offs rather than a single recommendation.",
38
+ "User prefers benefit-led headlines over feature-led ones. When writing marketing copy, prioritize pain/outcome framing over feature announcements. Use social proof as supporting evidence, not the lead.",
38
39
  approvedBy: null,
39
- createdAt: new Date(now - 5 * DAY),
40
+ createdAt: new Date(now - 14 * DAY),
40
41
  },
41
42
  {
42
43
  id: crypto.randomUUID(),
43
- profileId: "general",
44
+ profileId: "stagent-sample-gtm-launch-strategist",
44
45
  version: 2,
45
46
  content:
46
- "User prefers concise bullet-point summaries over paragraph-style output. When multiple options exist, present a ranked list with trade-offs rather than a single recommendation.",
47
- diff: "+ User prefers concise bullet-point summaries over paragraph-style output.\n+ When multiple options exist, present a ranked list with trade-offs rather than a single recommendation.",
47
+ "User prefers benefit-led headlines over feature-led ones. When writing marketing copy, prioritize pain/outcome framing over feature announcements. Use social proof as supporting evidence, not the lead.",
48
+ diff: "+ Benefit-led headlines preferred over feature-led.\n+ Pain/outcome framing > feature announcements.\n+ Social proof as support, not lead.",
48
49
  changeType: "approved",
49
- sourceTaskId: sourceTask1,
50
+ sourceTaskId: sourceTask2,
50
51
  proposalNotificationId: null,
51
52
  proposedAdditions: null,
52
53
  approvedBy: "user",
53
- createdAt: new Date(now - 5 * DAY + 2 * HOUR),
54
+ createdAt: new Date(now - 14 * DAY + 2 * HOUR),
54
55
  },
55
- // Researcher profile: proposal → rejected
56
+
57
+ // Content profile: proposal → approved (article length)
56
58
  {
57
59
  id: crypto.randomUUID(),
58
- profileId: "researcher",
60
+ profileId: "stagent-sample-content-production-editor",
59
61
  version: 1,
60
62
  content: null,
61
63
  diff: null,
62
64
  changeType: "proposal",
63
- sourceTaskId: sourceTask2,
65
+ sourceTaskId: sourceTask4,
64
66
  proposalNotificationId: null,
65
67
  proposedAdditions:
66
- "Always include academic citation format (APA) for sources. Limit research scope to peer-reviewed journals only.",
68
+ "Target 1,500-2,000 words for SEO articles. Shorter pieces don't rank for competitive keywords; longer ones have lower completion rates. Aim for Flesch-Kincaid score under 45.",
69
+ approvedBy: null,
70
+ createdAt: new Date(now - 10 * DAY),
71
+ },
72
+ {
73
+ id: crypto.randomUUID(),
74
+ profileId: "stagent-sample-content-production-editor",
75
+ version: 2,
76
+ content:
77
+ "Target 1,500-2,000 words for SEO articles. Shorter pieces don't rank for competitive keywords; longer ones have lower completion rates. Aim for Flesch-Kincaid score under 45.",
78
+ diff: "+ Target 1,500-2,000 words for SEO articles.\n+ FK score target: under 45.",
79
+ changeType: "approved",
80
+ sourceTaskId: sourceTask4,
81
+ proposalNotificationId: null,
82
+ proposedAdditions: null,
83
+ approvedBy: "user",
84
+ createdAt: new Date(now - 10 * DAY + 1 * HOUR),
85
+ },
86
+
87
+ // RevOps profile: proposal (deal stall threshold — pending)
88
+ {
89
+ id: crypto.randomUUID(),
90
+ profileId: "stagent-sample-revenue-ops-analyst",
91
+ version: 1,
92
+ content: null,
93
+ diff: null,
94
+ changeType: "proposal",
95
+ sourceTaskId: completedTaskIds[8] ?? null, // Pipeline snapshot (P7)
96
+ proposalNotificationId: null,
97
+ proposedAdditions:
98
+ "Deal stall threshold is 5 business days without activity. Flag deals exceeding this in every pipeline review. Coaching notes should include specific unblocking actions, not just the stall observation.",
67
99
  approvedBy: null,
68
100
  createdAt: new Date(now - 3 * DAY),
69
101
  },
102
+
103
+ // CS profile: proposal → approved (NPS threshold)
104
+ {
105
+ id: crypto.randomUUID(),
106
+ profileId: "stagent-sample-customer-success-analyst",
107
+ version: 1,
108
+ content: null,
109
+ diff: null,
110
+ changeType: "proposal",
111
+ sourceTaskId: sourceTask6,
112
+ proposalNotificationId: null,
113
+ proposedAdditions:
114
+ "NPS below 30 triggers immediate CSM outreach. Accounts without a workflow by Day 7 are at 82% churn risk — trigger proactive intervention at Day 5.",
115
+ approvedBy: null,
116
+ createdAt: new Date(now - 9 * DAY),
117
+ },
70
118
  {
71
119
  id: crypto.randomUUID(),
72
- profileId: "researcher",
120
+ profileId: "stagent-sample-customer-success-analyst",
121
+ version: 2,
122
+ content:
123
+ "NPS below 30 triggers immediate CSM outreach. Accounts without a workflow by Day 7 are at 82% churn risk — trigger proactive intervention at Day 5.",
124
+ diff: "+ NPS < 30 → immediate CSM outreach.\n+ No workflow by Day 7 → 82% churn risk.\n+ Proactive intervention at Day 5.",
125
+ changeType: "approved",
126
+ sourceTaskId: sourceTask6,
127
+ proposalNotificationId: null,
128
+ proposedAdditions: null,
129
+ approvedBy: "user",
130
+ createdAt: new Date(now - 9 * DAY + 1 * HOUR),
131
+ },
132
+
133
+ // Due Diligence profile: proposal → rejected (too broad)
134
+ {
135
+ id: crypto.randomUUID(),
136
+ profileId: "stagent-sample-due-diligence-analyst",
137
+ version: 1,
138
+ content: null,
139
+ diff: null,
140
+ changeType: "proposal",
141
+ sourceTaskId: completedTaskIds[6] ?? null,
142
+ proposalNotificationId: null,
143
+ proposedAdditions:
144
+ "Always include competitor comparison in every analysis, regardless of scope. Default to 5 competitors minimum.",
145
+ approvedBy: null,
146
+ createdAt: new Date(now - 5 * DAY),
147
+ },
148
+ {
149
+ id: crypto.randomUUID(),
150
+ profileId: "stagent-sample-due-diligence-analyst",
73
151
  version: 2,
74
152
  content: null,
75
153
  diff: null,
76
154
  changeType: "rejected",
77
- sourceTaskId: sourceTask2,
155
+ sourceTaskId: completedTaskIds[6] ?? null,
78
156
  proposalNotificationId: null,
79
157
  proposedAdditions: null,
80
158
  approvedBy: null,
81
- createdAt: new Date(now - 3 * DAY + 1 * HOUR),
159
+ createdAt: new Date(now - 5 * DAY + 30 * 60_000),
82
160
  },
83
- // General profile: second proposal (summarization)
161
+
162
+ // General profile: summarization
84
163
  {
85
164
  id: crypto.randomUUID(),
86
165
  profileId: "general",
87
- version: 3,
166
+ version: 1,
88
167
  content:
89
- "User prefers concise bullet-point summaries over paragraph-style output. When multiple options exist, present a ranked list with trade-offs rather than a single recommendation.",
168
+ "User prefers concise bullet-point summaries. When presenting options, use a ranked list with trade-offs. For reports, lead with the executive summary and recommendation before details.",
90
169
  diff: null,
91
170
  changeType: "summarization",
92
171
  sourceTaskId: null,