@todos-dev/cli 0.1.4 → 0.1.5

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 (2) hide show
  1. package/dist/index.js +207 -32
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -484,6 +484,11 @@ function text(s, details) {
484
484
  // src/lib/todoTools.ts
485
485
  var REQUEST_TIMEOUT_MS = 1e4;
486
486
  var LIST_CAP = 8e3;
487
+ function toolScope(step) {
488
+ if (step.workspace?.projectId) return { kind: "project", projectId: step.workspace.projectId };
489
+ if (step.chiefId) return { kind: "account", chiefId: step.chiefId };
490
+ return null;
491
+ }
487
492
  async function request(serverUrl, method, path, token, body) {
488
493
  const headers = { "Content-Type": "application/json" };
489
494
  if (token) headers["Authorization"] = `Bearer ${token}`;
@@ -511,60 +516,80 @@ function makeTodoTools(serverUrl, token, step) {
511
516
  ];
512
517
  }
513
518
  function makeListTodosTool(serverUrl, token, step) {
514
- const projectId = step.workspace?.projectId;
519
+ const scope = toolScope(step);
515
520
  return {
516
521
  name: "list_todos",
517
522
  label: "List Todos",
518
- description: `List the todos in this project so you can see existing/related work and find a todo to update. The first line lists the project's tags with their ids (usable as update_todo's tagIds). Returns each todo as "#<seq> [<phase>] <title> (id: <id>) [tags: \u2026]"; todos you created are marked (yours).`,
523
+ description: scope?.kind === "account" ? `List the todo boards of every project across the user's teams, grouped by project. Each project header carries its projectId (required by create_todo); each todo renders as "#<seq> [<phase>] <title> (id: <id>)".` : `List the todos in this project so you can see existing/related work and find a todo to update. The first line lists the project's tags with their ids (usable as update_todo's tagIds). Returns each todo as "#<seq> [<phase>] <title> (id: <id>) [tags: \u2026]"; todos you created are marked (yours).`,
519
524
  parameters: { type: "object", properties: {}, required: [], additionalProperties: false },
520
525
  async execute() {
521
- if (!projectId) return text2("No project context for this turn \u2014 todos are unavailable.");
522
- const [reply, tagsReply] = await Promise.all([
523
- request(serverUrl, "GET", `/api/projects/${projectId}/todos`, token),
524
- request(serverUrl, "GET", `/api/projects/${projectId}/tags`, token)
525
- ]);
526
- if (!reply.ok) return text2(errorText(reply, "Failed to list todos"));
527
- const todos = reply.body ?? [];
528
- if (!todos.length) return text2("No todos in this project yet.");
529
- const tags = tagsReply.ok ? tagsReply.body ?? [] : [];
530
- const tagName = new Map(tags.map((t) => [t.id, t.name]));
531
- const header = tags.length ? `Project tags: ${tags.map((t) => `${t.name} (id: ${t.id})`).join(", ")}
526
+ if (scope?.kind === "project") {
527
+ const { projectId } = scope;
528
+ const [reply, tagsReply] = await Promise.all([
529
+ request(serverUrl, "GET", `/api/projects/${projectId}/todos`, token),
530
+ request(serverUrl, "GET", `/api/projects/${projectId}/tags`, token)
531
+ ]);
532
+ if (!reply.ok) return text2(errorText(reply, "Failed to list todos"));
533
+ const todos = reply.body ?? [];
534
+ if (!todos.length) return text2("No todos in this project yet.");
535
+ const tags = tagsReply.ok ? tagsReply.body ?? [] : [];
536
+ const tagName = new Map(tags.map((t) => [t.id, t.name]));
537
+ const header = tags.length ? `Project tags: ${tags.map((t) => `${t.name} (id: ${t.id})`).join(", ")}
532
538
  ` : "";
533
- const lines = todos.map((t) => {
534
- const mine = t.createdBy === step.agent.agentId ? " (yours)" : "";
535
- const names = (t.tagIds ?? []).map((id) => tagName.get(id)).filter(Boolean);
536
- const tagsStr = names.length ? ` [tags: ${names.join(", ")}]` : "";
537
- return `#${t.seqNum} [${t.phase}] ${t.title} (id: ${t.id})${tagsStr}${mine}`;
538
- });
539
- let out = header + lines.join("\n");
540
- if (out.length > LIST_CAP) out = out.slice(0, LIST_CAP) + "\n\u2026(truncated)";
541
- return text2(out);
539
+ const lines = todos.map((t) => {
540
+ const mine = t.createdBy === step.agent.agentId ? " (yours)" : "";
541
+ const names = (t.tagIds ?? []).map((id) => tagName.get(id)).filter(Boolean);
542
+ const tagsStr = names.length ? ` [tags: ${names.join(", ")}]` : "";
543
+ return `#${t.seqNum} [${t.phase}] ${t.title} (id: ${t.id})${tagsStr}${mine}`;
544
+ });
545
+ let out = header + lines.join("\n");
546
+ if (out.length > LIST_CAP) out = out.slice(0, LIST_CAP) + "\n\u2026(truncated)";
547
+ return text2(out);
548
+ }
549
+ if (scope?.kind === "account") {
550
+ const reply = await request(serverUrl, "GET", `/api/machine/chief/todos?chiefId=${encodeURIComponent(scope.chiefId)}`, token);
551
+ if (!reply.ok) return text2(errorText(reply, "Failed to list todos"));
552
+ const projects = reply.body?.projects ?? [];
553
+ if (!projects.length) return text2("No projects in your teams yet.");
554
+ const blocks = projects.map((p) => {
555
+ const lines = p.todos.length ? p.todos.map((t) => `#${t.seqNum} [${t.phase}] ${t.title} (id: ${t.id})`).join("\n") : "(no todos)";
556
+ return `## ${p.name} (projectId: ${p.id})
557
+ ${lines}`;
558
+ });
559
+ let out = blocks.join("\n\n");
560
+ if (out.length > LIST_CAP) out = out.slice(0, LIST_CAP) + "\n\u2026(truncated)";
561
+ return text2(out);
562
+ }
563
+ return text2("No project context for this turn \u2014 todos are unavailable.");
542
564
  }
543
565
  };
544
566
  }
545
567
  function makeCreateTodoTool(serverUrl, token, step) {
546
- const projectId = step.workspace?.projectId;
568
+ const scope = toolScope(step);
569
+ const accountScope = scope?.kind === "account";
547
570
  return {
548
571
  name: "create_todo",
549
572
  label: "Create Todo",
550
- description: "Create a follow-up todo for work you discovered but that is out of scope for the current task (e.g. a refactor, a separate bug, a next step). The new todo is added to the project backlog and does NOT run automatically \u2014 the user decides when to start it. Use a clear, actionable title and put the context/acceptance criteria in spec.",
573
+ description: accountScope ? "Create a todo in one of the user's projects (projectId comes from list_todos's project headers). The new todo lands in that project's backlog and does NOT run automatically \u2014 propose it with propose_builds when it should run. Use a clear, actionable title and put the objective, boundaries, and acceptance criteria in spec." : "Create a follow-up todo for work you discovered but that is out of scope for the current task (e.g. a refactor, a separate bug, a next step). The new todo is added to the project backlog and does NOT run automatically \u2014 the user decides when to start it. Use a clear, actionable title and put the context/acceptance criteria in spec.",
551
574
  parameters: {
552
575
  type: "object",
553
576
  properties: {
554
- title: { type: "string", description: "Short, actionable title for the follow-up work." },
577
+ ...accountScope ? { projectId: { type: "string", description: "Target project id (from list_todos)." } } : {},
578
+ title: { type: "string", description: "Short, actionable title for the work." },
555
579
  spec: { type: "string", description: "Details: what to do, why, and any acceptance criteria. Optional but recommended." }
556
580
  },
557
- required: ["title"],
581
+ required: accountScope ? ["projectId", "title"] : ["title"],
558
582
  additionalProperties: false
559
583
  },
560
584
  async execute(_id, params) {
561
- if (!projectId) return text2("No project context for this turn \u2014 cannot create a todo.");
562
585
  const p = params ?? {};
586
+ const projectId = scope?.kind === "project" ? scope.projectId : p.projectId;
587
+ if (!scope || !projectId) return text2(accountScope ? "A projectId is required (find it with list_todos)." : "No project context for this turn \u2014 cannot create a todo.");
563
588
  if (!p.title?.trim()) return text2("A title is required to create a todo.");
564
589
  const reply = await request(serverUrl, "POST", `/api/projects/${projectId}/todos`, token, {
565
590
  title: p.title,
566
591
  spec: p.spec ?? "",
567
- buildId: step.conversationId
592
+ buildId: scope.kind === "account" ? scope.chiefId : step.conversationId
568
593
  });
569
594
  if (!reply.ok) return text2(errorText(reply, "Failed to create todo"));
570
595
  const t = reply.body;
@@ -573,10 +598,11 @@ function makeCreateTodoTool(serverUrl, token, step) {
573
598
  };
574
599
  }
575
600
  function makeUpdateTodoTool(serverUrl, token, step) {
601
+ const scope = toolScope(step);
576
602
  return {
577
603
  name: "update_todo",
578
604
  label: "Update Todo",
579
- description: `Update a todo YOU created (only your own \u2014 found via list_todos, marked "(yours)"). You can change its title, spec, or tags (tag ids come from the "Project tags" line of list_todos). Use this to refine a follow-up todo as you learn more. You cannot edit todos created by others or the user, change a todo's phase, or start a build.`,
605
+ description: scope?.kind === "account" ? "Update a todo's title or spec \u2014 use this to groom a todo before proposing it: make the spec state the objective, boundaries, and acceptance criteria. You cannot change a todo's phase, assignment, or start a build." : `Update a todo YOU created (only your own \u2014 found via list_todos, marked "(yours)"). You can change its title, spec, or tags (tag ids come from the "Project tags" line of list_todos). Use this to refine a follow-up todo as you learn more. You cannot edit todos created by others or the user, change a todo's phase, or start a build.`,
580
606
  parameters: {
581
607
  type: "object",
582
608
  properties: {
@@ -591,7 +617,7 @@ function makeUpdateTodoTool(serverUrl, token, step) {
591
617
  async execute(_id, params) {
592
618
  const p = params ?? {};
593
619
  if (!p.id) return text2("A todo id is required (find it with list_todos).");
594
- const patch = { buildId: step.conversationId };
620
+ const patch = { buildId: scope?.kind === "account" ? scope.chiefId : step.conversationId };
595
621
  if (p.title !== void 0) patch.title = p.title;
596
622
  if (p.spec !== void 0) patch.spec = p.spec;
597
623
  if (p.tagIds !== void 0) patch.tagIds = p.tagIds;
@@ -603,6 +629,126 @@ function makeUpdateTodoTool(serverUrl, token, step) {
603
629
  };
604
630
  }
605
631
 
632
+ // src/lib/chiefTools.ts
633
+ function makeChiefTools(serverUrl, token, step) {
634
+ return [
635
+ makeProposeBuildsTool(serverUrl, token, step),
636
+ makeRunBuildsTool(serverUrl, token, step),
637
+ makeUpdateMemoryTool(serverUrl, token, step)
638
+ ];
639
+ }
640
+ var DISPATCH_ITEMS_SCHEMA = {
641
+ type: "array",
642
+ minItems: 1,
643
+ items: {
644
+ type: "object",
645
+ properties: {
646
+ todoId: { type: "string", description: "The todo to run (id from list_todos)." },
647
+ withPlan: { type: "boolean", description: "Start with a plan step the user confirms before implementation. Default false." },
648
+ agentId: { type: "string", description: "Suggested agent (from the available-agents list). Omit to use the todo's own assignment." },
649
+ thinkingLevel: { type: "string", description: "Suggested thinking level for the agent (only with agentId)." },
650
+ reason: { type: "string", description: "One line on why this todo, this agent, now." }
651
+ },
652
+ required: ["todoId"],
653
+ additionalProperties: false
654
+ }
655
+ };
656
+ function itemsToBody(items) {
657
+ return items.map((i) => ({
658
+ todoId: i.todoId,
659
+ ...i.withPlan !== void 0 ? { withPlan: i.withPlan } : {},
660
+ ...i.agentId ? { agent: { agentId: i.agentId, ...i.thinkingLevel ? { thinkingLevel: i.thinkingLevel } : {} } } : {},
661
+ ...i.reason ? { reason: i.reason } : {}
662
+ }));
663
+ }
664
+ function makeProposeBuildsTool(serverUrl, token, step) {
665
+ const chiefId = step.chiefId;
666
+ return {
667
+ name: "propose_builds",
668
+ label: "Propose Builds",
669
+ description: "Propose which todos to run next. This does NOT start anything \u2014 it creates a proposal card the user reviews, adjusts, and runs. Use this for work YOU are initiating; when the user has explicitly asked to run something, use run_builds instead. Pick the agent (agentId from the available-agents list) and thinking level per item to match the work; set withPlan for tasks that deserve a reviewed plan first. Groom each todo (update_todo: objective, boundaries, acceptance criteria) BEFORE proposing it. On success, reference the returned doc id in your reply as [Run N todos](doc:<id>) so the user sees the card.",
670
+ parameters: {
671
+ type: "object",
672
+ properties: {
673
+ items: DISPATCH_ITEMS_SCHEMA,
674
+ summary: { type: "string", description: "One-line summary of the proposal as a whole (optional)." }
675
+ },
676
+ required: ["items"],
677
+ additionalProperties: false
678
+ },
679
+ async execute(_id, params) {
680
+ if (!chiefId) return text2("propose_builds is only available in the chief conversation.");
681
+ const p = params ?? {};
682
+ const items = (p.items ?? []).filter((i) => i?.todoId);
683
+ if (!items.length) return text2("At least one item with a todoId is required.");
684
+ const reply = await request(serverUrl, "POST", "/api/machine/chief/proposals", token, {
685
+ chiefId,
686
+ items: itemsToBody(items),
687
+ ...p.summary ? { summary: p.summary } : {}
688
+ });
689
+ if (!reply.ok) return text2(errorText(reply, "Failed to create the proposal"));
690
+ const docId = reply.body?.docId;
691
+ return text2(`Created a proposal with ${items.length} item(s). Reference it in your reply as [Run ${items.length} todo${items.length > 1 ? "s" : ""}](doc:${docId}) so the user sees the proposal card.`);
692
+ }
693
+ };
694
+ }
695
+ function makeRunBuildsTool(serverUrl, token, step) {
696
+ const chiefId = step.chiefId;
697
+ return {
698
+ name: "run_builds",
699
+ label: "Run Builds",
700
+ description: "Start builds for todos IMMEDIATELY \u2014 no confirmation card. Use this ONLY when the user has explicitly asked for the work to run in this conversation (their message is the approval); for work you are initiating yourself, use propose_builds instead. Same item shape as propose_builds: pick agent/thinkingLevel per item, withPlan for tasks needing a reviewed plan. Groom each todo before running it.",
701
+ parameters: {
702
+ type: "object",
703
+ properties: {
704
+ items: DISPATCH_ITEMS_SCHEMA
705
+ },
706
+ required: ["items"],
707
+ additionalProperties: false
708
+ },
709
+ async execute(_id, params) {
710
+ if (!chiefId) return text2("run_builds is only available in the chief conversation.");
711
+ const p = params ?? {};
712
+ const items = (p.items ?? []).filter((i) => i?.todoId);
713
+ if (!items.length) return text2("At least one item with a todoId is required.");
714
+ const reply = await request(serverUrl, "POST", "/api/machine/chief/builds", token, {
715
+ chiefId,
716
+ items: itemsToBody(items)
717
+ });
718
+ if (!reply.ok) return text2(errorText(reply, "Failed to start builds"));
719
+ const started = reply.body?.started ?? [];
720
+ const skipped = items.length - started.length;
721
+ return text2(
722
+ `Started ${started.length} build(s): ${started.map((s) => `#${s.seqNum}`).join(", ")}.` + (skipped > 0 ? ` ${skipped} item(s) were skipped (phase changed or no resolvable agent).` : "") + " Tell the user what is now running and with which agents."
723
+ );
724
+ }
725
+ };
726
+ }
727
+ function makeUpdateMemoryTool(serverUrl, token, step) {
728
+ const chiefId = step.chiefId;
729
+ return {
730
+ name: "update_memory",
731
+ label: "Update Memory",
732
+ description: "Rewrite your persistent memory \u2014 the notes injected into every future turn, surviving session resets. FULL REPLACEMENT: send the complete new text, not a diff; prune stale entries to stay under the size cap. Save immediately when you learn a durable routing preference, a user preference, or a lesson \u2014 do not wait. Every update is kept as a version the user can restore.",
733
+ parameters: {
734
+ type: "object",
735
+ properties: {
736
+ content: { type: "string", description: "The complete new memory text (replaces the old entirely)." }
737
+ },
738
+ required: ["content"],
739
+ additionalProperties: false
740
+ },
741
+ async execute(_id, params) {
742
+ if (!chiefId) return text2("update_memory is only available in the chief conversation.");
743
+ const p = params ?? {};
744
+ if (!p.content?.trim()) return text2("Memory content is required (full replacement text).");
745
+ const reply = await request(serverUrl, "POST", "/api/machine/chief/memory", token, { chiefId, content: p.content });
746
+ if (!reply.ok) return text2(errorText(reply, "Failed to update memory"));
747
+ return text2("Memory updated. It will be injected into your future turns.");
748
+ }
749
+ };
750
+ }
751
+
606
752
  // src/lib/sessionStore.ts
607
753
  var import_node_fs3 = require("node:fs");
608
754
  var import_promises = require("node:fs/promises");
@@ -1212,7 +1358,8 @@ async function executeStep(step, serverUrl, token, tunnel) {
1212
1358
  const skills = await materializeSkills(step.skills, agentDir);
1213
1359
  const extraCustomTools = [
1214
1360
  makeClientShellTool(tunnel, conversationId, runnersRef),
1215
- ...makeTodoTools(serverUrl, token, step)
1361
+ ...makeTodoTools(serverUrl, token, step),
1362
+ ...makeChiefTools(serverUrl, token, step)
1216
1363
  ];
1217
1364
  const session = await createSession(sdk, {
1218
1365
  authStorage,
@@ -16031,7 +16178,8 @@ var STEP_DEF = {
16031
16178
  implement_revision: { track: "implement", sink: "chat", phase: { busy: "building", rest: "review", notify: "build_review" } },
16032
16179
  merge: { track: "implement", sink: "chat", phase: { busy: "building", rest: "review", notify: "build_review" } },
16033
16180
  plan_review: { track: "plan", sink: "review" },
16034
- implement_review: { track: "implement", sink: "review" }
16181
+ implement_review: { track: "implement", sink: "review" },
16182
+ chief: { sink: "chief" }
16035
16183
  };
16036
16184
  var isReviewStep = (k) => STEP_DEF[k].sink === "review";
16037
16185
  var REVIEW_STEP_KINDS = Object.keys(STEP_DEF).filter(isReviewStep);
@@ -16108,6 +16256,33 @@ var UpdateTodoRequestSchema = external_exports.object({
16108
16256
  });
16109
16257
  var MachineCreateTodoRequestSchema = CreateTodoRequestSchema.extend({ buildId: external_exports.string() });
16110
16258
  var MachineUpdateTodoRequestSchema = UpdateTodoRequestSchema.omit({ assignment: true }).extend({ buildId: external_exports.string() });
16259
+ var UpdateChiefRequestSchema = external_exports.object({
16260
+ agent: AgentEntrySchema.nullable().optional(),
16261
+ charter: external_exports.string().optional()
16262
+ });
16263
+ var ChiefStepRequestSchema = external_exports.object({
16264
+ content: external_exports.string().trim().min(1)
16265
+ });
16266
+ var DispatchItemSchema = external_exports.object({
16267
+ todoId: external_exports.string().min(1),
16268
+ withPlan: external_exports.boolean().optional(),
16269
+ agent: AgentEntrySchema.optional(),
16270
+ reason: external_exports.string().optional()
16271
+ });
16272
+ var MAX_DISPATCH_ITEMS = 20;
16273
+ var MachineProposeBuildsRequestSchema = external_exports.object({
16274
+ chiefId: external_exports.string().min(1),
16275
+ items: external_exports.array(DispatchItemSchema).min(1).max(MAX_DISPATCH_ITEMS),
16276
+ summary: external_exports.string().optional()
16277
+ });
16278
+ var MachineRunBuildsRequestSchema = external_exports.object({
16279
+ chiefId: external_exports.string().min(1),
16280
+ items: external_exports.array(DispatchItemSchema).min(1).max(MAX_DISPATCH_ITEMS)
16281
+ });
16282
+ var MachineUpdateMemoryRequestSchema = external_exports.object({
16283
+ chiefId: external_exports.string().min(1),
16284
+ content: external_exports.string().min(1)
16285
+ });
16111
16286
  var TriggerBuildRequestSchema = external_exports.object({
16112
16287
  todoIds: external_exports.array(external_exports.string()).min(1),
16113
16288
  // One-time assignment override; falls back to todo.assignment. Server enriches model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todos-dev/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "bin": {
5
5
  "tds": "dist/index.js"
6
6
  },
@@ -27,12 +27,12 @@
27
27
  "@tds/types": "0.1.0"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@todos-dev/cli-darwin-arm64": "0.1.4",
31
- "@todos-dev/cli-darwin-x64": "0.1.4",
32
- "@todos-dev/cli-linux-x64": "0.1.4",
33
- "@todos-dev/cli-linux-arm64": "0.1.4",
34
- "@todos-dev/cli-win32-x64": "0.1.4",
35
- "@todos-dev/cli-win32-arm64": "0.1.4"
30
+ "@todos-dev/cli-darwin-arm64": "0.1.5",
31
+ "@todos-dev/cli-darwin-x64": "0.1.5",
32
+ "@todos-dev/cli-linux-x64": "0.1.5",
33
+ "@todos-dev/cli-linux-arm64": "0.1.5",
34
+ "@todos-dev/cli-win32-x64": "0.1.5",
35
+ "@todos-dev/cli-win32-arm64": "0.1.5"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "tsx watch src/index.ts",