@wrongstack/tools 0.5.5 → 0.5.6

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/builtin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { spawn } from 'child_process';
2
- import { buildChildEnv, stripAnsi, detectNewlineStyle, normalizeToLf, toStyle, atomicWrite, unifiedDiff, compileGlob, loadPlan, emptyPlan, clearPlan, savePlan, removePlanItem, setPlanItemStatus, addPlanItem, formatPlan } from '@wrongstack/core';
2
+ import { buildChildEnv, stripAnsi, detectNewlineStyle, normalizeToLf, toStyle, atomicWrite, unifiedDiff, compileGlob, loadPlan, emptyPlan, clearPlan, savePlan, getPlanTemplate, addPlanItem, deriveTodosFromPlanItem, removePlanItem, setPlanItemStatus, formatPlan } from '@wrongstack/core';
3
3
  import * as path from 'path';
4
4
  import { dirname } from 'path';
5
5
  import * as os from 'os';
@@ -2799,8 +2799,8 @@ function extractPatchedFiles(output) {
2799
2799
  var planTool = {
2800
2800
  name: "plan",
2801
2801
  category: "Session",
2802
- description: "Inspect or edit the strategic plan board for this session. Plans persist across resume (unlike todos). Use this to lay out the multi-step approach before diving in, then mark steps in_progress/done as the work proceeds.",
2803
- usageHint: "Set action to one of: show | add | start | done | remove | clear. Pass `title` for add. Pass `target` (item id, 1-based index, or title substring) for start/done/remove. Always returns the formatted plan plus open/total counts.",
2802
+ description: "Inspect or edit the strategic plan board for this session. Plans persist across resume (unlike todos). Use this to lay out the multi-step approach before diving in, then mark steps in_progress/done as the work proceeds. Promote a plan item to todos to start working on it. Apply templates for common workflows.",
2803
+ usageHint: 'Set action to one of: show | add | start | done | remove | promote | derive | template_use | clear. Pass `title` for add. Pass `target` (item id, 1-based index, or title substring) for start/done/remove/promote/derive. Pass `subtasks` for promote/derive to break the plan item into multiple todos. Pass `template` (e.g. "new-feature", "bug-fix", "refactor", "release") for template_use. Always returns the formatted plan plus open/total counts.',
2804
2804
  permission: "auto",
2805
2805
  mutating: false,
2806
2806
  timeoutMs: 2e3,
@@ -2809,13 +2809,22 @@ var planTool = {
2809
2809
  properties: {
2810
2810
  action: {
2811
2811
  type: "string",
2812
- enum: ["show", "add", "start", "done", "remove", "clear"]
2812
+ enum: ["show", "add", "start", "done", "remove", "promote", "derive", "template_use", "clear"]
2813
2813
  },
2814
2814
  title: { type: "string", description: "Required when action = add." },
2815
2815
  details: { type: "string", description: "Optional extra context for add." },
2816
2816
  target: {
2817
2817
  type: "string",
2818
- description: "Plan item id, 1-based index, or title substring. Required for start/done/remove."
2818
+ description: "Plan item id, 1-based index, or title substring. Required for start/done/remove/promote/derive."
2819
+ },
2820
+ subtasks: {
2821
+ type: "array",
2822
+ items: { type: "string" },
2823
+ description: "Optional subtasks for promote/derive. If omitted, a single todo is created from the plan item title."
2824
+ },
2825
+ template: {
2826
+ type: "string",
2827
+ description: "Template name for template_use action. Available: new-feature, bug-fix, refactor, release, security-audit, onboarding."
2819
2828
  }
2820
2829
  },
2821
2830
  required: ["action"]
@@ -2874,6 +2883,35 @@ var planTool = {
2874
2883
  await savePlan(planPath, plan);
2875
2884
  break;
2876
2885
  }
2886
+ case "promote":
2887
+ case "derive": {
2888
+ if (!input.target) {
2889
+ return mkResult(plan, false, `${input.action} requires \`target\` (id|index|substring).`);
2890
+ }
2891
+ const derived = deriveTodosFromPlanItem(plan, input.target, input.subtasks);
2892
+ if (!derived) {
2893
+ return mkResult(plan, false, `No plan item matched "${input.target}".`);
2894
+ }
2895
+ plan = derived.plan;
2896
+ await savePlan(planPath, plan);
2897
+ ctx.state.replaceTodos(derived.todos);
2898
+ return mkResult(plan, true, `${input.action} ok \u2014 ${derived.todos.length} todo(s) created.`, derived.todos);
2899
+ }
2900
+ case "template_use": {
2901
+ const templateName = input.template?.trim();
2902
+ if (!templateName) {
2903
+ return mkResult(plan, false, "template_use requires `template` name.");
2904
+ }
2905
+ const template = getPlanTemplate(templateName);
2906
+ if (!template) {
2907
+ return mkResult(plan, false, `Unknown template "${templateName}".`);
2908
+ }
2909
+ for (const item of template.items) {
2910
+ ({ plan } = addPlanItem(plan, item.title, item.details));
2911
+ }
2912
+ await savePlan(planPath, plan);
2913
+ return mkResult(plan, true, `Applied template "${template.name}" \u2014 ${template.items.length} items added.`);
2914
+ }
2877
2915
  case "clear":
2878
2916
  plan = clearPlan(plan);
2879
2917
  await savePlan(planPath, plan);
@@ -2884,14 +2922,15 @@ var planTool = {
2884
2922
  return mkResult(plan, true, `Plan ${input.action} ok.`);
2885
2923
  }
2886
2924
  };
2887
- function mkResult(plan, ok, message) {
2925
+ function mkResult(plan, ok, message, todos) {
2888
2926
  const open = plan.items.filter((i) => i.status !== "done").length;
2889
2927
  return {
2890
2928
  ok,
2891
2929
  message,
2892
2930
  plan: formatPlan(plan),
2893
2931
  count: plan.items.length,
2894
- open
2932
+ open,
2933
+ todos
2895
2934
  };
2896
2935
  }
2897
2936
  var MAX_BYTES2 = 5 * 1024 * 1024;