create-feltkit 0.4.0 → 0.5.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.
- package/bin/create.js +3 -3
- package/package.json +4 -4
- package/scaffold.d.ts +1 -1
- package/scaffold.js +8 -5
- package/template/README.md +72 -177
- package/template/_gitignore +4 -0
- package/template/agent/agent.ts +28 -0
- package/template/agent/channels/eve.ts +6 -0
- package/template/agent/instructions.md +24 -0
- package/template/agent/lib/deterministic.ts +46 -0
- package/template/agent/lib/feltkit-capabilities.json +294 -0
- package/template/agent/tools/crew_artifacts_create.ts +4 -0
- package/template/agent/tools/crew_context_read.ts +4 -0
- package/template/agent/tools/crew_context_record.ts +4 -0
- package/template/agent/tools/crew_context_search.ts +4 -0
- package/template/agent/tools/crew_decisions_propose.ts +4 -0
- package/template/agent/tools/crew_tasks_add.ts +6 -0
- package/template/agent/tools/crew_tasks_list.ts +4 -0
- package/template/agent/tools/crew_tasks_note.ts +4 -0
- package/template/agent/tools/crew_workspace_overview.ts +4 -0
- package/template/agent/tools/crew_workstreams_update.ts +6 -0
- package/template/agent/tools/web_fetch.ts +1 -0
- package/template/agent/tools/web_search.ts +3 -0
- package/template/feltkit/_generated/api.ts +8 -4
- package/template/feltkit/activity.ts +26 -0
- package/template/feltkit/app.ts +147 -54
- package/template/feltkit/boards.ts +10 -0
- package/template/feltkit/decisions.ts +99 -0
- package/template/feltkit/knowledge.ts +119 -0
- package/template/feltkit/model.ts +96 -0
- package/template/feltkit/work.ts +45 -0
- package/template/feltkit/workspace.ts +171 -0
- package/template/index.html +1 -1
- package/template/native/App.tsx +249 -0
- package/template/package.json +11 -5
- package/template/shared/rules.ts +23 -0
- package/template/src/App.tsx +177 -528
- package/template/src/screens/activity.tsx +66 -0
- package/template/src/screens/agent.tsx +188 -0
- package/template/src/screens/context.tsx +71 -0
- package/template/src/screens/decisions.tsx +89 -0
- package/template/src/screens/home.tsx +140 -0
- package/template/src/screens/team.tsx +13 -0
- package/template/src/screens/work.tsx +149 -0
- package/template/src/styles.css +201 -118
- package/template/src/ui.tsx +179 -0
- package/template/tests/crew.test.ts +111 -0
- package/template/tsconfig.json +18 -3
- package/template-managed/Dockerfile +2 -2
- package/template-managed/README.md +1 -1
- package/template-managed/package.json +3 -3
- package/template-tasks/README.md +383 -0
- package/template-tasks/_gitignore +12 -0
- package/template-tasks/feltkit/_generated/api.ts +10 -0
- package/template-tasks/feltkit/app.ts +73 -0
- package/template-tasks/index.html +17 -0
- package/template-tasks/native/App.tsx +220 -0
- package/template-tasks/native/native.json +5 -0
- package/template-tasks/package.json +30 -0
- package/template-tasks/public/apple-touch-icon.png +0 -0
- package/template-tasks/public/favicon.png +0 -0
- package/template-tasks/public/theme.js +7 -0
- package/template-tasks/shared/rules.ts +18 -0
- package/template-tasks/src/App.tsx +557 -0
- package/template-tasks/src/main.tsx +17 -0
- package/template-tasks/src/styles.css +134 -0
- package/template-tasks/src/theme.tsx +58 -0
- package/template-tasks/tsconfig.json +16 -0
- package/template-tasks/vite.config.ts +6 -0
- /package/{template → template-tasks}/feltkit/inbox.ts +0 -0
- /package/{template → template-tasks}/feltkit/projects.ts +0 -0
- /package/{template → template-tasks}/feltkit/tasks.ts +0 -0
- /package/{template → template-tasks}/public/feltkit-mark.png +0 -0
- /package/{template → template-tasks}/tests/tasks.test.ts +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decision log. Anyone who contributes may propose a question (with a recommendation); a person decides it,
|
|
3
|
+
* with the rationale, the alternatives considered and the evidence. Revisiting a decision records a new one that
|
|
4
|
+
* supersedes it: the earlier decision, and who made it, stays in the log.
|
|
5
|
+
*/
|
|
6
|
+
import { fail, s } from "@feltdb/feltkit";
|
|
7
|
+
import { app, context, decisions } from "./app.js";
|
|
8
|
+
import { actorOf, remember } from "./model.js";
|
|
9
|
+
|
|
10
|
+
async function checkEvidence(ctx: any, evidence: string[]) {
|
|
11
|
+
for (const id of evidence) if (!(await ctx.db.get(context, id))) fail("NOT_FOUND", `No context item ${id} to cite as evidence.`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const list = app.query({
|
|
15
|
+
access: "crew.read",
|
|
16
|
+
args: { status: s.optional(s.enum(["proposed", "decided", "superseded", "declined"])) },
|
|
17
|
+
handler: async (ctx, { status }) => ctx.db.find(decisions, status ? { status } : {}, { orderBy: [{ field: "proposedAt", direction: "desc" }], limit: 500 }),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** A decision and the chain it belongs to (what it superseded, what superseded it). */
|
|
21
|
+
export const history = app.query({
|
|
22
|
+
access: "crew.read",
|
|
23
|
+
args: { id: s.string() },
|
|
24
|
+
handler: async (ctx, { id }) => {
|
|
25
|
+
const chain = [];
|
|
26
|
+
let at = await ctx.db.get(decisions, id);
|
|
27
|
+
if (!at) fail("NOT_FOUND", "No such decision.");
|
|
28
|
+
while (at?.supersededBy) at = await ctx.db.get(decisions, at.supersededBy);
|
|
29
|
+
while (at) {
|
|
30
|
+
chain.push(at);
|
|
31
|
+
at = at.supersedes ? await ctx.db.get(decisions, at.supersedes) : null;
|
|
32
|
+
}
|
|
33
|
+
const cited = new Set(chain.flatMap((d) => d.evidence));
|
|
34
|
+
const evidence = [];
|
|
35
|
+
for (const ref of cited) {
|
|
36
|
+
const c = await ctx.db.get(context, ref);
|
|
37
|
+
if (c) evidence.push({ id: c.id, title: c.title, source: c.source, confidence: c.confidence });
|
|
38
|
+
}
|
|
39
|
+
return { chain, evidence };
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const propose = app.mutation({
|
|
44
|
+
access: "crew.contribute",
|
|
45
|
+
args: {
|
|
46
|
+
question: s.string({ minLength: 1, maxLength: 300 }),
|
|
47
|
+
recommendation: s.optional(s.string({ maxLength: 2000 })),
|
|
48
|
+
rationale: s.optional(s.string({ maxLength: 4000 })),
|
|
49
|
+
alternatives: s.optional(s.array(s.string({ maxLength: 400 }), { maxItems: 10 })),
|
|
50
|
+
evidence: s.optional(s.array(s.string(), { maxItems: 20 })),
|
|
51
|
+
workstreamId: s.optional(s.string()),
|
|
52
|
+
},
|
|
53
|
+
returns: s.object({ id: s.string() }),
|
|
54
|
+
capability: { name: "crew.decisions.propose", description: "Propose a decision for the workspace: the question, your recommendation, the rationale, alternatives considered, and context items as evidence. A person decides it." },
|
|
55
|
+
handler: async (ctx, { question, recommendation, rationale, alternatives, evidence, workstreamId }) => {
|
|
56
|
+
await checkEvidence(ctx, evidence ?? []);
|
|
57
|
+
const by = actorOf(ctx);
|
|
58
|
+
const id = await ctx.db.insert(decisions, { question: question.trim(), status: "proposed", ...(recommendation ? { decision: recommendation.trim() } : {}), ...(rationale ? { rationale: rationale.trim() } : {}), alternatives: alternatives ?? [], evidence: evidence ?? [], ...(workstreamId ? { workstreamId } : {}), proposedBy: by, proposedAt: Date.now() });
|
|
59
|
+
await remember(ctx, "decision.proposed", { id, question: question.trim() });
|
|
60
|
+
return { id };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/** A person decides a proposed question: what was decided, and why. Or declines to decide it. */
|
|
65
|
+
export const decide = app.mutation({
|
|
66
|
+
access: "crew.decide",
|
|
67
|
+
args: { id: s.string(), outcome: s.enum(["decided", "declined"]), decision: s.optional(s.string({ minLength: 1, maxLength: 2000 })), rationale: s.optional(s.string({ maxLength: 4000 })), evidence: s.optional(s.array(s.string(), { maxItems: 20 })) },
|
|
68
|
+
handler: async (ctx, { id, outcome, decision, rationale, evidence }) => {
|
|
69
|
+
const d = await ctx.db.get(decisions, id);
|
|
70
|
+
if (!d) fail("NOT_FOUND", "No such decision.");
|
|
71
|
+
if (d.status !== "proposed") fail("CONFLICT", `This question was already ${d.status}.`);
|
|
72
|
+
const by = actorOf(ctx);
|
|
73
|
+
if (by.type !== "person") fail("FORBIDDEN", "A person decides.");
|
|
74
|
+
if (outcome === "decided" && !(decision ?? d.decision)) fail("INVALID_ARGUMENT", "Say what was decided.");
|
|
75
|
+
if (evidence) await checkEvidence(ctx, evidence);
|
|
76
|
+
await ctx.db.patch(decisions, id, { status: outcome, ...(decision ? { decision: decision.trim() } : {}), ...(rationale ? { rationale: rationale.trim() } : {}), ...(evidence ? { evidence } : {}), decidedBy: by, decidedAt: Date.now() });
|
|
77
|
+
await remember(ctx, outcome === "decided" ? "decision.made" : "decision.declined", { id, question: d.question });
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/** Revisit a decision: a new decision that supersedes it. The earlier one is kept, marked superseded. */
|
|
82
|
+
export const revisit = app.mutation({
|
|
83
|
+
access: "crew.decide",
|
|
84
|
+
args: { id: s.string(), decision: s.string({ minLength: 1, maxLength: 2000 }), rationale: s.string({ minLength: 1, maxLength: 4000 }), evidence: s.optional(s.array(s.string(), { maxItems: 20 })) },
|
|
85
|
+
returns: s.object({ id: s.string() }),
|
|
86
|
+
handler: async (ctx, { id, decision, rationale, evidence }) => {
|
|
87
|
+
const d = await ctx.db.get(decisions, id);
|
|
88
|
+
if (!d) fail("NOT_FOUND", "No such decision.");
|
|
89
|
+
if (d.status !== "decided") fail("FAILED_PRECONDITION", "Only a decision that was made can be revisited.");
|
|
90
|
+
const by = actorOf(ctx);
|
|
91
|
+
if (by.type !== "person") fail("FORBIDDEN", "A person decides.");
|
|
92
|
+
if (evidence) await checkEvidence(ctx, evidence);
|
|
93
|
+
const at = Date.now();
|
|
94
|
+
const next = await ctx.db.insert(decisions, { question: d.question, status: "decided", decision: decision.trim(), rationale: rationale.trim(), alternatives: d.alternatives, evidence: evidence ?? d.evidence, ...(d.workstreamId ? { workstreamId: d.workstreamId } : {}), supersedes: id, proposedBy: by, proposedAt: at, decidedBy: by, decidedAt: at });
|
|
95
|
+
await ctx.db.patch(decisions, id, { status: "superseded", supersededBy: next });
|
|
96
|
+
await remember(ctx, "decision.revisited", { id: next, supersedes: id, question: d.question });
|
|
97
|
+
return { id: next };
|
|
98
|
+
},
|
|
99
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared context: notes, research, findings, references, reports and artifacts, each with its source (a person,
|
|
3
|
+
* the agent, an external reference, or starter content) and its standing (hypothesis, unverified, verified).
|
|
4
|
+
* Only a person verifies; verifying records who and when. Artifacts are files (AppPort Services Files) with a
|
|
5
|
+
* context record that says what they are and where they came from.
|
|
6
|
+
*/
|
|
7
|
+
import { fail, s } from "@feltdb/feltkit";
|
|
8
|
+
import { app, context, workstreams } from "./app.js";
|
|
9
|
+
import { actorOf, remember } from "./model.js";
|
|
10
|
+
|
|
11
|
+
const Kind = s.enum(["note", "finding", "research", "reference", "report"]);
|
|
12
|
+
|
|
13
|
+
async function checkWorkstream(ctx: any, workstreamId: string | undefined) {
|
|
14
|
+
if (workstreamId !== undefined && !(await ctx.db.get(workstreams, workstreamId))) fail("NOT_FOUND", "No such workstream.");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const list = app.query({
|
|
18
|
+
access: "crew.read",
|
|
19
|
+
args: { workstreamId: s.optional(s.string()), kind: s.optional(s.enum(["note", "finding", "research", "reference", "report", "artifact"])), confidence: s.optional(s.enum(["hypothesis", "unverified", "verified"])) },
|
|
20
|
+
handler: async (ctx, { workstreamId, kind, confidence }) => {
|
|
21
|
+
const where = { ...(workstreamId ? { workstreamId } : {}), ...(kind ? { kind } : {}), ...(confidence ? { confidence } : {}) };
|
|
22
|
+
return ctx.db.find(context, where, { orderBy: [{ field: "createdAt", direction: "desc" }], limit: 500 });
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const search = app.query({
|
|
27
|
+
access: "crew.read",
|
|
28
|
+
args: { text: s.string({ minLength: 1, maxLength: 200 }) },
|
|
29
|
+
returns: s.array(s.object({ id: s.string(), kind: s.string(), title: s.string(), excerpt: s.string(), source: s.string(), confidence: s.string(), workstreamId: s.optional(s.string()) })),
|
|
30
|
+
capability: { name: "crew.context.search", description: "Search the workspace's context (notes, research, findings, references, reports, artifacts) by text. Each result says its source and whether it is a hypothesis, unverified, or verified." },
|
|
31
|
+
handler: async (ctx, { text }) => {
|
|
32
|
+
const rows = await ctx.db.search(context, { text: text.trim(), limit: 20 });
|
|
33
|
+
return rows.map((c) => ({ id: c.id, kind: c.kind, title: c.title, excerpt: c.body.slice(0, 400), source: c.source, confidence: c.confidence, ...(c.workstreamId ? { workstreamId: c.workstreamId } : {}) }));
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const get = app.query({
|
|
38
|
+
access: "crew.read",
|
|
39
|
+
args: { id: s.string() },
|
|
40
|
+
returns: s.unknown(),
|
|
41
|
+
capability: { name: "crew.context.read", description: "Read one context item in full: its text, source, standing and links." },
|
|
42
|
+
handler: async (ctx, { id }) => {
|
|
43
|
+
const item = await ctx.db.get(context, id);
|
|
44
|
+
if (!item) fail("NOT_FOUND", "No such context item.");
|
|
45
|
+
return item;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** Add to the workspace's context. A person's addition is "unverified" unless they mark it verified; the agent's is always unverified. */
|
|
50
|
+
export const record = app.mutation({
|
|
51
|
+
access: "crew.contribute",
|
|
52
|
+
args: {
|
|
53
|
+
kind: Kind,
|
|
54
|
+
title: s.string({ minLength: 1, maxLength: 160 }),
|
|
55
|
+
body: s.string({ minLength: 1, maxLength: 20000 }),
|
|
56
|
+
url: s.optional(s.string({ maxLength: 2000 })),
|
|
57
|
+
workstreamId: s.optional(s.string()),
|
|
58
|
+
threadId: s.optional(s.string()),
|
|
59
|
+
},
|
|
60
|
+
returns: s.object({ id: s.string() }),
|
|
61
|
+
capability: { name: "crew.context.record", description: "Record a finding, research, reference, note or progress report in the workspace's shared context. Name the source URL for external information. It is stored as unverified until a person verifies it." },
|
|
62
|
+
handler: async (ctx, { kind, title, body, url, workstreamId, threadId }) => {
|
|
63
|
+
await checkWorkstream(ctx, workstreamId);
|
|
64
|
+
const by = actorOf(ctx);
|
|
65
|
+
const source = url ? "external" : by.type === "agent" ? "agent" : "person";
|
|
66
|
+
const id = await ctx.db.insert(context, { kind, title: title.trim(), body: body.trim(), source, confidence: "unverified", ...(url ? { url } : {}), ...(workstreamId ? { workstreamId } : {}), ...(threadId ? { threadId } : {}), createdBy: by, createdAt: Date.now() });
|
|
67
|
+
await remember(ctx, "context.recorded", { id, kind, title: title.trim(), source });
|
|
68
|
+
return { id };
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/** A person marks a context item as verified evidence (or takes that back). */
|
|
73
|
+
export const verify = app.mutation({
|
|
74
|
+
access: "crew.decide",
|
|
75
|
+
args: { id: s.string(), verified: s.boolean() },
|
|
76
|
+
handler: async (ctx, { id, verified }) => {
|
|
77
|
+
const item = await ctx.db.get(context, id);
|
|
78
|
+
if (!item) fail("NOT_FOUND", "No such context item.");
|
|
79
|
+
const by = actorOf(ctx);
|
|
80
|
+
if (by.type !== "person") fail("FORBIDDEN", "Only a person verifies evidence.");
|
|
81
|
+
if (item.source === "starter" && verified) fail("FAILED_PRECONDITION", "Starter content is an example or a hypothesis. Record what you found, and verify that.");
|
|
82
|
+
await ctx.db.patch(context, id, verified ? { confidence: "verified", verifiedBy: by, verifiedAt: Date.now() } : { confidence: "unverified", verifiedBy: undefined, verifiedAt: undefined });
|
|
83
|
+
await remember(ctx, verified ? "context.verified" : "context.unverified", { id, title: item.title });
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/** Write an artifact (a document: a plan, a brief, an interview guide) as a file, with a context record for it. */
|
|
88
|
+
export const createArtifact = app.mutation({
|
|
89
|
+
access: "crew.contribute",
|
|
90
|
+
args: {
|
|
91
|
+
title: s.string({ minLength: 1, maxLength: 160 }),
|
|
92
|
+
filename: s.string({ minLength: 1, maxLength: 120, pattern: "^[A-Za-z0-9][A-Za-z0-9 ._-]*\\.(md|txt|csv)$" }),
|
|
93
|
+
content: s.string({ minLength: 1, maxLength: 200000 }),
|
|
94
|
+
summary: s.string({ minLength: 1, maxLength: 2000 }),
|
|
95
|
+
workstreamId: s.optional(s.string()),
|
|
96
|
+
},
|
|
97
|
+
returns: s.object({ id: s.string(), fileId: s.string() }),
|
|
98
|
+
capability: { name: "crew.artifacts.create", description: "Create a document artifact (Markdown, text or CSV) such as a plan, brief, guide or analysis, stored as a file in the workspace with a summary." },
|
|
99
|
+
handler: async (ctx, { title, filename, content, summary, workstreamId }) => {
|
|
100
|
+
await checkWorkstream(ctx, workstreamId);
|
|
101
|
+
const by = actorOf(ctx);
|
|
102
|
+
const type = filename.endsWith(".csv") ? "text/csv" : filename.endsWith(".md") ? "text/markdown" : "text/plain";
|
|
103
|
+
const file = await ctx.services.files.upload({ name: filename, contentType: type, content, metadata: { kind: "artifact" } });
|
|
104
|
+
const id = await ctx.db.insert(context, { kind: "artifact", title: title.trim(), body: summary.trim(), source: by.type === "agent" ? "agent" : "person", confidence: "unverified", fileId: file.id, ...(workstreamId ? { workstreamId } : {}), createdBy: by, createdAt: Date.now() });
|
|
105
|
+
await remember(ctx, "artifact.created", { id, title: title.trim(), filename });
|
|
106
|
+
return { id, fileId: file.id };
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/** A short-lived link to read an artifact's file. */
|
|
111
|
+
export const artifactLink = app.query({
|
|
112
|
+
access: "crew.read",
|
|
113
|
+
args: { id: s.string() },
|
|
114
|
+
handler: async (ctx, { id }) => {
|
|
115
|
+
const item = await ctx.db.get(context, id);
|
|
116
|
+
if (!item?.fileId) fail("NOT_FOUND", "No such artifact.");
|
|
117
|
+
return ctx.services.files.link(item.fileId, { expiresInSeconds: 600, disposition: "inline" });
|
|
118
|
+
},
|
|
119
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared rules for Crew's functions: who did something, what the workspace is, and its history.
|
|
3
|
+
* Not functions themselves (nothing here is callable from a client).
|
|
4
|
+
*/
|
|
5
|
+
import { fail } from "@feltdb/feltkit";
|
|
6
|
+
import { missions, trail } from "./app.js";
|
|
7
|
+
|
|
8
|
+
export type Actor = { id: string; type: string; name?: string };
|
|
9
|
+
|
|
10
|
+
/** The verified caller as an actor: a person, or the workspace agent (a worker). */
|
|
11
|
+
export function actorOf(ctx: any): Actor {
|
|
12
|
+
const p = ctx.auth.requirePrincipal();
|
|
13
|
+
return { id: p.id, type: p.type === "user" ? "person" : "agent", ...(p.displayName ? { name: p.displayName } : {}) };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The workspace's mission record (one per workspace), or a precise refusal before setup. */
|
|
17
|
+
export async function requireMission(ctx: any) {
|
|
18
|
+
const [mission] = await ctx.db.find(missions, {}, { limit: 1 });
|
|
19
|
+
if (!mission) fail("FAILED_PRECONDITION", "This workspace has no mission yet: set it up first.");
|
|
20
|
+
return mission;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** One entry in the workspace's history: what happened, by whom (recorded by FeltKit), with references. */
|
|
24
|
+
export async function remember(ctx: any, type: string, data: Record<string, unknown>) {
|
|
25
|
+
const mission = await requireMission(ctx);
|
|
26
|
+
await trail.record(ctx, { subject: "workspace", id: mission.id, type, data });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const LAUNCH_A_BUSINESS = {
|
|
30
|
+
title: "Launch a Business",
|
|
31
|
+
outcome:
|
|
32
|
+
"Validate and launch a viable business by identifying a real customer problem, validating demand, defining an offer, establishing operational readiness, and executing a launch.",
|
|
33
|
+
workstreams: [
|
|
34
|
+
{
|
|
35
|
+
name: "Customer Discovery",
|
|
36
|
+
outcome: "Evidence that a specific customer has a problem worth paying to solve.",
|
|
37
|
+
tasks: [
|
|
38
|
+
"Identify target customer segments",
|
|
39
|
+
"Research customer problems",
|
|
40
|
+
"Gather competitive evidence",
|
|
41
|
+
"Prepare and conduct customer interviews",
|
|
42
|
+
"Record validation findings",
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Product & Offer",
|
|
47
|
+
outcome: "An offer customers understand and want, with a minimum version we can deliver.",
|
|
48
|
+
tasks: ["Define the offer", "Identify differentiators", "Establish pricing hypotheses", "Define the minimum viable product or service"],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "Business Model",
|
|
52
|
+
outcome: "A revenue model whose unit economics hold under stated assumptions.",
|
|
53
|
+
tasks: ["Choose the revenue model", "Map the cost structure", "Estimate unit economics", "List assumptions and financial risks"],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Operations",
|
|
57
|
+
outcome: "We can deliver to the first customers reliably and lawfully.",
|
|
58
|
+
tasks: ["Design the delivery model", "Choose tools and systems", "Write the core processes", "Review legal and operational considerations"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "Go-to-Market",
|
|
62
|
+
outcome: "A launch plan with channels tested by small experiments.",
|
|
63
|
+
tasks: ["Draft positioning", "Write messaging", "Pick acquisition channels to test", "Plan the launch", "Design the first experiments"],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
context: [
|
|
67
|
+
{
|
|
68
|
+
kind: "note" as const,
|
|
69
|
+
title: "Starting hypothesis: who we serve",
|
|
70
|
+
body: "Hypothesis (starter content, not verified): independent service businesses with 2–20 people lose hours each week coordinating work across email, chat and spreadsheets. Replace this with your own and test it in Customer Discovery.",
|
|
71
|
+
workstream: "Customer Discovery",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
kind: "note" as const,
|
|
75
|
+
title: "Example interview guide",
|
|
76
|
+
body: "Example (starter content): 1. Tell me about the last time this problem came up. 2. What did you do about it? 3. What did that cost you in time or money? 4. What have you tried? 5. What would make this a non-issue? Ask about past behaviour, not future intentions.",
|
|
77
|
+
workstream: "Customer Discovery",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
kind: "note" as const,
|
|
81
|
+
title: "Pricing starting point",
|
|
82
|
+
body: "Hypothesis (starter content, not verified): a monthly subscription between $30 and $90 per team. To test: willingness to pay in interviews, and what customers pay today for the workaround.",
|
|
83
|
+
workstream: "Product & Offer",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
kind: "note" as const,
|
|
87
|
+
title: "Unit economics to fill in",
|
|
88
|
+
body: "Template (starter content): price per customer per month; cost to serve per month; acquisition cost per customer; expected months retained. Lifetime value = margin × months retained. Target: lifetime value at least 3× acquisition cost.",
|
|
89
|
+
workstream: "Business Model",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
decision: {
|
|
93
|
+
question: "Which customer segment do we validate first?",
|
|
94
|
+
alternatives: ["Independent agencies", "Home-services operators", "Small professional practices"],
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work, as the workspace agent reaches it. People use Boards directly (`api.boards.*`: claim, start, complete,
|
|
3
|
+
* dependencies, follow-ups); these capabilities are the agent's narrower view of the same Boards records. Adding
|
|
4
|
+
* work to the plan needs a person's approval of the exact task; reporting progress does not.
|
|
5
|
+
*/
|
|
6
|
+
import { fail, s } from "@feltdb/feltkit";
|
|
7
|
+
import { app, workstreams } from "./app.js";
|
|
8
|
+
import { boards } from "./boards.js";
|
|
9
|
+
import { remember } from "./model.js";
|
|
10
|
+
|
|
11
|
+
export const tasks = app.query({
|
|
12
|
+
access: "crew.read",
|
|
13
|
+
args: { workstreamId: s.string() },
|
|
14
|
+
returns: s.array(s.object({ id: s.string(), title: s.string(), status: s.string(), body: s.optional(s.string()), messages: s.number() })),
|
|
15
|
+
capability: { name: "crew.tasks.list", description: "The tasks in a workstream with their status (open, ready, blocked, claimed, in_progress, completed, failed, cancelled)." },
|
|
16
|
+
handler: async (ctx, { workstreamId }) => {
|
|
17
|
+
const w = await ctx.db.get(workstreams, workstreamId);
|
|
18
|
+
if (!w) fail("NOT_FOUND", "No such workstream.");
|
|
19
|
+
const threads = (await boards.run(ctx, "listThreads", { channelId: w.channelId, kind: "task", limit: 200 })) as Array<{ id: string; title: string; status: string; body?: string; messageCount?: number }>;
|
|
20
|
+
return threads.map((t) => ({ id: t.id, title: t.title, status: t.status, ...(t.body ? { body: t.body.slice(0, 1000) } : {}), messages: Number(t.messageCount ?? 0) }));
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const addTask = app.mutation({
|
|
25
|
+
access: "crew.plan",
|
|
26
|
+
args: { workstreamId: s.string(), title: s.string({ minLength: 1, maxLength: 200 }), details: s.optional(s.string({ maxLength: 4000 })) },
|
|
27
|
+
returns: s.object({ id: s.string() }),
|
|
28
|
+
approval: "required",
|
|
29
|
+
capability: { name: "crew.tasks.add", description: "Add a task to a workstream's plan. A person approves it before it is added." },
|
|
30
|
+
handler: async (ctx, { workstreamId, title, details }) => {
|
|
31
|
+
const w = await ctx.db.get(workstreams, workstreamId);
|
|
32
|
+
if (!w) fail("NOT_FOUND", "No such workstream.");
|
|
33
|
+
const { id } = (await boards.run(ctx, "createThread", { channelId: w.channelId, kind: "task", title: title.trim(), ...(details?.trim() ? { body: details.trim() } : {}), labels: [], metadata: {} })) as { id: string };
|
|
34
|
+
await remember(ctx, "task.added", { id, title: title.trim(), workstream: w.name });
|
|
35
|
+
return { id };
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const note = app.mutation({
|
|
40
|
+
access: "crew.contribute",
|
|
41
|
+
args: { taskId: s.string(), text: s.string({ minLength: 1, maxLength: 8000 }) },
|
|
42
|
+
returns: s.object({ id: s.string() }),
|
|
43
|
+
capability: { name: "crew.tasks.note", description: "Post a progress note on a task: what was done, what was found, what is next." },
|
|
44
|
+
handler: async (ctx, { taskId, text }) => boards.run(ctx, "postMessage", { threadId: taskId, text: text.trim() }),
|
|
45
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace: its mission, its workstreams, and Mission Control (what it is trying to do, where it is, what
|
|
3
|
+
* needs attention, what to do next). Every answer here is read from the workspace's own records at the time of
|
|
4
|
+
* the call; nothing is estimated.
|
|
5
|
+
*/
|
|
6
|
+
import { fail, s } from "@feltdb/feltkit";
|
|
7
|
+
import { app, context, decisions, missions, workstreams } from "./app.js";
|
|
8
|
+
import { boards } from "./boards.js";
|
|
9
|
+
import { actorOf, LAUNCH_A_BUSINESS, remember, requireMission } from "./model.js";
|
|
10
|
+
|
|
11
|
+
const Stage = s.enum(["defining", "validating", "building", "launching", "operating"]);
|
|
12
|
+
const Status = s.enum(["not-started", "on-track", "at-risk", "blocked", "done"]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Set up a new workspace: its mission, a board for its work, and either the "Launch a Business" starter
|
|
16
|
+
* (five workstreams, starter tasks, notes marked as hypotheses, one open decision) or one empty workstream.
|
|
17
|
+
*/
|
|
18
|
+
export const setup = app.mutation({
|
|
19
|
+
access: "crew.manage",
|
|
20
|
+
args: {
|
|
21
|
+
title: s.string({ minLength: 1, maxLength: 120 }),
|
|
22
|
+
outcome: s.string({ minLength: 1, maxLength: 2000 }),
|
|
23
|
+
template: s.enum(["launch-a-business", "blank"]),
|
|
24
|
+
},
|
|
25
|
+
returns: s.object({ missionId: s.string(), boardId: s.string() }),
|
|
26
|
+
handler: async (ctx, { title, outcome, template }) => {
|
|
27
|
+
if ((await ctx.db.find(missions, {}, { limit: 1 })).length) fail("CONFLICT", "This workspace is already set up.");
|
|
28
|
+
const by = actorOf(ctx);
|
|
29
|
+
const at = Date.now();
|
|
30
|
+
const { id: boardId } = (await boards.run(ctx, "createBoard", { name: title.trim(), description: outcome.trim(), visibility: "open" })) as { id: string };
|
|
31
|
+
const missionId = await ctx.db.insert(missions, { title: title.trim(), outcome: outcome.trim(), stage: "defining", boardId, ...(template === "blank" ? {} : { template }), createdBy: by, createdAt: at, updatedAt: at });
|
|
32
|
+
const plan = template === "launch-a-business" ? LAUNCH_A_BUSINESS.workstreams : [{ name: "General", outcome: "Everything that does not belong to a workstream yet.", tasks: [] as string[] }];
|
|
33
|
+
const byName = new Map<string, string>();
|
|
34
|
+
for (const [position, stream] of plan.entries()) {
|
|
35
|
+
const { id: channelId } = (await boards.run(ctx, "createChannel", { boardId, name: stream.name, purpose: stream.outcome })) as { id: string };
|
|
36
|
+
const workstreamId = await ctx.db.insert(workstreams, { channelId, name: stream.name, outcome: stream.outcome, status: "not-started", position, updatedAt: at, updatedBy: by });
|
|
37
|
+
byName.set(stream.name, workstreamId);
|
|
38
|
+
for (const task of stream.tasks) await boards.run(ctx, "createThread", { channelId, kind: "task", title: task, labels: [], metadata: { starter: true } });
|
|
39
|
+
}
|
|
40
|
+
if (template === "launch-a-business") {
|
|
41
|
+
for (const note of LAUNCH_A_BUSINESS.context) {
|
|
42
|
+
await ctx.db.insert(context, { kind: note.kind, title: note.title, body: note.body, source: "starter", confidence: "hypothesis", workstreamId: byName.get(note.workstream), createdBy: by, createdAt: at });
|
|
43
|
+
}
|
|
44
|
+
await ctx.db.insert(decisions, { question: LAUNCH_A_BUSINESS.decision.question, status: "proposed", alternatives: LAUNCH_A_BUSINESS.decision.alternatives, evidence: [], workstreamId: byName.get("Customer Discovery"), proposedBy: by, proposedAt: at });
|
|
45
|
+
}
|
|
46
|
+
await remember(ctx, "workspace.created", { title: title.trim(), template });
|
|
47
|
+
return { missionId, boardId };
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** Change the mission. `version` is the one you read: a mission someone else changed since is refused, not overwritten. */
|
|
52
|
+
export const updateMission = app.mutation({
|
|
53
|
+
access: "crew.manage",
|
|
54
|
+
args: { version: s.number(), title: s.optional(s.string({ minLength: 1, maxLength: 120 })), outcome: s.optional(s.string({ minLength: 1, maxLength: 2000 })), stage: s.optional(Stage) },
|
|
55
|
+
handler: async (ctx, { version, title, outcome, stage }) => {
|
|
56
|
+
const mission = await requireMission(ctx);
|
|
57
|
+
if (mission.__version !== version) fail("CONFLICT", "Someone changed the mission since you opened it. Review their change, then edit again.");
|
|
58
|
+
await ctx.db.patch(missions, mission.id, { ...(title ? { title: title.trim() } : {}), ...(outcome ? { outcome: outcome.trim() } : {}), ...(stage ? { stage } : {}), updatedAt: Date.now() });
|
|
59
|
+
await remember(ctx, "mission.updated", { ...(title ? { title } : {}), ...(stage ? { stage } : {}), ...(outcome ? { outcome: true } : {}) });
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const mission = app.query({
|
|
64
|
+
access: "crew.read",
|
|
65
|
+
handler: async (ctx) => {
|
|
66
|
+
const [m] = await ctx.db.find(missions, {}, { limit: 1 });
|
|
67
|
+
return m ?? null;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/** The workstreams with their health and, from Boards, their work by status. */
|
|
72
|
+
export const listWorkstreams = app.query({
|
|
73
|
+
access: "crew.read",
|
|
74
|
+
handler: async (ctx) => {
|
|
75
|
+
const rows = await ctx.db.find(workstreams, {}, { orderBy: [{ field: "position", direction: "asc" }] });
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const w of rows) {
|
|
78
|
+
const threads = (await boards.run(ctx, "listThreads", { channelId: w.channelId, kind: "task", limit: 500 })) as Array<{ status: string }>;
|
|
79
|
+
const counts: Record<string, number> = {};
|
|
80
|
+
for (const t of threads) counts[t.status] = (counts[t.status] ?? 0) + 1;
|
|
81
|
+
const evidence = (await ctx.db.find(context, { workstreamId: w.id, confidence: "verified" })).length;
|
|
82
|
+
out.push({ ...w, tasks: threads.length, counts, evidence });
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/** Change a workstream's health. Refused when someone changed it since `version`. */
|
|
89
|
+
export const updateWorkstream = app.mutation({
|
|
90
|
+
access: "crew.plan",
|
|
91
|
+
args: { workstreamId: s.string(), status: Status, note: s.string({ minLength: 1, maxLength: 1000 }), version: s.optional(s.number()) },
|
|
92
|
+
returns: s.object({ id: s.string(), status: s.string() }),
|
|
93
|
+
approval: "required",
|
|
94
|
+
capability: { name: "crew.workstreams.update", description: "Change a workstream's status (not-started, on-track, at-risk, blocked, done), with the reason. A person approves it." },
|
|
95
|
+
handler: async (ctx, { workstreamId, status, note, version }) => {
|
|
96
|
+
const w = await ctx.db.get(workstreams, workstreamId);
|
|
97
|
+
if (!w) fail("NOT_FOUND", "No such workstream.");
|
|
98
|
+
if (version !== undefined && w.__version !== version) fail("CONFLICT", "Someone changed this workstream since you opened it.");
|
|
99
|
+
const by = actorOf(ctx);
|
|
100
|
+
await ctx.db.patch(workstreams, workstreamId, { status, updatedAt: Date.now(), updatedBy: by });
|
|
101
|
+
await remember(ctx, "workstream.status", { workstreamId, name: w.name, from: w.status, to: status, note });
|
|
102
|
+
return { id: workstreamId, status };
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Mission Control: the mission and stage, the workstreams' health, what needs attention (blocked work, pending
|
|
108
|
+
* decisions, unverified findings), progress as evidence (verified context, decisions made, tasks done with a
|
|
109
|
+
* result), and the next thing to do, chosen by fixed rules from those records.
|
|
110
|
+
*/
|
|
111
|
+
export const overview = app.query({
|
|
112
|
+
access: "crew.read",
|
|
113
|
+
capability: { name: "crew.workspace.overview", description: "The workspace: mission, stage, workstreams with status and task counts, pending decisions, recent findings, what needs attention, and the operator's standing guidance for the agent (guidance)." },
|
|
114
|
+
returns: s.unknown(),
|
|
115
|
+
handler: async (ctx) => {
|
|
116
|
+
const [m] = await ctx.db.find(missions, {}, { limit: 1 });
|
|
117
|
+
if (!m) return { setup: false };
|
|
118
|
+
const streams = await ctx.db.find(workstreams, {}, { orderBy: [{ field: "position", direction: "asc" }] });
|
|
119
|
+
const work: Array<{ workstream: string; workstreamId: string; id: string; title: string; status: string; claimedBy?: string }> = [];
|
|
120
|
+
for (const w of streams) {
|
|
121
|
+
const threads = (await boards.run(ctx, "listThreads", { channelId: w.channelId, kind: "task", limit: 500 })) as Array<{ id: string; title: string; status: string; claim?: { holder?: string } | null }>;
|
|
122
|
+
for (const t of threads) work.push({ workstream: w.name, workstreamId: w.id, id: t.id, title: t.title, status: t.status, ...(t.claim?.holder ? { claimedBy: t.claim.holder } : {}) });
|
|
123
|
+
}
|
|
124
|
+
const allContext = await ctx.db.find(context, {}, { orderBy: [{ field: "createdAt", direction: "desc" }] });
|
|
125
|
+
const allDecisions = await ctx.db.find(decisions, {}, { orderBy: [{ field: "proposedAt", direction: "desc" }] });
|
|
126
|
+
const pendingDecisions = allDecisions.filter((d) => d.status === "proposed");
|
|
127
|
+
const blocked = work.filter((t) => t.status === "blocked");
|
|
128
|
+
const done = work.filter((t) => t.status === "completed");
|
|
129
|
+
const inProgress = work.filter((t) => t.status === "in_progress" || t.status === "claimed");
|
|
130
|
+
const verified = allContext.filter((c) => c.confidence === "verified");
|
|
131
|
+
const unverified = allContext.filter((c) => c.confidence === "unverified");
|
|
132
|
+
const members = await ctx.tenancy.members();
|
|
133
|
+
const people = members.filter((x: { type: string }) => x.type === "user");
|
|
134
|
+
const agentActive = members.some((x: { type: string; principalId: string }) => x.type === "agent" && x.principalId.startsWith("worker:eve-crew"));
|
|
135
|
+
const decided = allDecisions.filter((d) => d.status === "decided");
|
|
136
|
+
const guidance = (await ctx.services.configuration.get("AGENT_GUIDANCE").catch(() => null)) ?? null;
|
|
137
|
+
const next = nextAction({ people: people.length, agentActive, blocked: blocked.length, pendingDecisions: pendingDecisions.length, unverified: unverified.length, verified: verified.length, inProgress: inProgress.length, ready: work.filter((t) => t.status === "ready" || t.status === "open").length });
|
|
138
|
+
return {
|
|
139
|
+
setup: true,
|
|
140
|
+
mission: { id: m.id, title: m.title, outcome: m.outcome, stage: m.stage, boardId: m.boardId, version: m.__version, template: m.template ?? null },
|
|
141
|
+
workstreams: streams.map((w) => {
|
|
142
|
+
const mine = work.filter((t) => t.workstreamId === w.id);
|
|
143
|
+
return { id: w.id, channelId: w.channelId, name: w.name, outcome: w.outcome, status: w.status, version: w.__version, tasks: mine.length, done: mine.filter((t) => t.status === "completed").length, active: mine.filter((t) => t.status === "in_progress" || t.status === "claimed").length, blocked: mine.filter((t) => t.status === "blocked").length, evidence: verified.filter((c) => c.workstreamId === w.id).length };
|
|
144
|
+
}),
|
|
145
|
+
evidence: { verified: verified.length, unverified: unverified.length, hypotheses: allContext.filter((c) => c.confidence === "hypothesis").length, decisions: decided.length, tasksDone: done.length, tasks: work.length },
|
|
146
|
+
attention: {
|
|
147
|
+
blocked: blocked.slice(0, 10),
|
|
148
|
+
decisions: pendingDecisions.slice(0, 10).map((d) => ({ id: d.id, question: d.question, proposedBy: d.proposedBy })),
|
|
149
|
+
unverified: unverified.slice(0, 10).map((c) => ({ id: c.id, title: c.title, source: c.source })),
|
|
150
|
+
},
|
|
151
|
+
inProgress: inProgress.slice(0, 10),
|
|
152
|
+
recentFindings: allContext.filter((c) => c.kind !== "note" || c.source !== "starter").slice(0, 8).map((c) => ({ id: c.id, kind: c.kind, title: c.title, source: c.source, confidence: c.confidence, createdAt: c.createdAt })),
|
|
153
|
+
people: people.length,
|
|
154
|
+
agentActive,
|
|
155
|
+
guidance,
|
|
156
|
+
next,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
/** The next useful step, by fixed rules in priority order. */
|
|
162
|
+
export function nextAction(state: { people: number; agentActive: boolean; blocked: number; pendingDecisions: number; unverified: number; verified: number; inProgress: number; ready: number }): { action: string; title: string; detail: string } {
|
|
163
|
+
if (!state.agentActive) return { action: "activate-agent", title: "Activate the workspace agent", detail: "It can research, record findings and propose next steps. It acts only through this workspace's capabilities, and asks before it changes your plan." };
|
|
164
|
+
if (state.people < 2) return { action: "invite", title: "Invite a collaborator", detail: "Work here is shared: everyone sees the same mission, work and history as it changes." };
|
|
165
|
+
if (state.blocked) return { action: "unblock", title: `Unblock ${state.blocked} task${state.blocked === 1 ? "" : "s"}`, detail: "Blocked work holds up the tasks that depend on it." };
|
|
166
|
+
if (state.pendingDecisions) return { action: "decide", title: `Decide ${state.pendingDecisions} open question${state.pendingDecisions === 1 ? "" : "s"}`, detail: "Decisions record what you chose, why, and the evidence behind it." };
|
|
167
|
+
if (state.unverified) return { action: "verify", title: `Review ${state.unverified} unverified finding${state.unverified === 1 ? "" : "s"}`, detail: "Check the source and mark what holds up as verified evidence." };
|
|
168
|
+
if (state.verified === 0) return { action: "research", title: "Ask the agent to research your first assumption", detail: "Start with who the customer is and what problem they pay to solve." };
|
|
169
|
+
if (state.inProgress === 0 && state.ready) return { action: "start", title: "Pick up a ready task", detail: "Claim it so others (and the agent) know it is yours." };
|
|
170
|
+
return { action: "review", title: "Review progress with the agent", detail: "Ask it what changed and what it recommends next." };
|
|
171
|
+
}
|
package/template/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<link rel="icon" href="/favicon.png" type="image/png" />
|
|
8
8
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
9
|
-
<title>
|
|
9
|
+
<title>Crew</title>
|
|
10
10
|
<!-- The saved light/dark choice, applied before first paint (src/theme.tsx). -->
|
|
11
11
|
<script vite-ignore src="/theme.js"></script>
|
|
12
12
|
</head>
|