spets 0.1.81 → 0.1.82

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 +167 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2647,7 +2647,7 @@ var StepExecutor = class {
2647
2647
  import { spawn, spawnSync } from "child_process";
2648
2648
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync7, existsSync as existsSync9, mkdirSync as mkdirSync6 } from "fs";
2649
2649
  import { dirname as dirname3 } from "path";
2650
- import { input, select, confirm } from "@inquirer/prompts";
2650
+ import { input, select, confirm, editor } from "@inquirer/prompts";
2651
2651
  var CLIAIAdapter = class {
2652
2652
  claudeCommand;
2653
2653
  constructor(claudeCommand = "claude") {
@@ -2881,6 +2881,91 @@ Context: ${question.context}`);
2881
2881
  };
2882
2882
  console.log(`${icons[type]} ${message}`);
2883
2883
  }
2884
+ async askKnowledge(checkpoint) {
2885
+ console.log("\n" + "=".repeat(60));
2886
+ console.log("\u{1F4DA} Knowledge Extraction");
2887
+ console.log("=".repeat(60));
2888
+ if (checkpoint.guide) {
2889
+ console.log("\n\u{1F4D6} Guide:");
2890
+ console.log(checkpoint.guide);
2891
+ }
2892
+ if (checkpoint.suggestedKnowledge.length === 0) {
2893
+ console.log("\nNo knowledge suggestions from this workflow.");
2894
+ const shouldAdd = await confirm({
2895
+ message: "Would you like to add custom knowledge entries?",
2896
+ default: false
2897
+ });
2898
+ if (!shouldAdd) {
2899
+ return { entries: [], skipped: true };
2900
+ }
2901
+ } else {
2902
+ console.log("\n\u{1F4A1} Suggested knowledge from this workflow:\n");
2903
+ for (const suggestion of checkpoint.suggestedKnowledge) {
2904
+ console.log(` \u{1F4DD} ${suggestion.filename}`);
2905
+ console.log(` Reason: ${suggestion.reason}`);
2906
+ console.log(` Preview: ${suggestion.content.substring(0, 100)}${suggestion.content.length > 100 ? "..." : ""}`);
2907
+ console.log("");
2908
+ }
2909
+ }
2910
+ const action = await select({
2911
+ message: "What would you like to do?",
2912
+ choices: [
2913
+ { value: "save_suggested", name: "\u2705 Save suggested knowledge" },
2914
+ { value: "edit", name: "\u270F\uFE0F Edit and save (opens editor)" },
2915
+ { value: "skip", name: "\u23ED\uFE0F Skip - don't save any knowledge" }
2916
+ ]
2917
+ });
2918
+ if (action === "skip") {
2919
+ return { entries: [], skipped: true };
2920
+ }
2921
+ if (action === "save_suggested") {
2922
+ return {
2923
+ entries: checkpoint.suggestedKnowledge.map((s) => ({
2924
+ filename: s.filename,
2925
+ content: s.content
2926
+ })),
2927
+ skipped: false
2928
+ };
2929
+ }
2930
+ const entries = [];
2931
+ for (const suggestion of checkpoint.suggestedKnowledge) {
2932
+ const shouldSave = await confirm({
2933
+ message: `Save "${suggestion.filename}"?`,
2934
+ default: true
2935
+ });
2936
+ if (shouldSave) {
2937
+ const filename = await input({
2938
+ message: "Filename (without .md):",
2939
+ default: suggestion.filename
2940
+ });
2941
+ const content = await editor({
2942
+ message: "Content (save and close editor):",
2943
+ default: suggestion.content
2944
+ });
2945
+ entries.push({ filename, content });
2946
+ }
2947
+ }
2948
+ let addMore = await confirm({
2949
+ message: "Add more custom knowledge entries?",
2950
+ default: false
2951
+ });
2952
+ while (addMore) {
2953
+ const filename = await input({
2954
+ message: "Filename (without .md):"
2955
+ });
2956
+ const content = await editor({
2957
+ message: "Content (save and close editor):"
2958
+ });
2959
+ if (filename && content) {
2960
+ entries.push({ filename, content });
2961
+ }
2962
+ addMore = await confirm({
2963
+ message: "Add another entry?",
2964
+ default: false
2965
+ });
2966
+ }
2967
+ return { entries, skipped: entries.length === 0 };
2968
+ }
2884
2969
  };
2885
2970
  var CLISystemAdapter = class {
2886
2971
  readFile(path) {
@@ -3097,6 +3182,57 @@ var GitHubIOAdapter = class {
3097
3182
  };
3098
3183
  console.log(`${icons[type]} ${message}`);
3099
3184
  }
3185
+ async askKnowledge(checkpoint) {
3186
+ const comment = this.formatKnowledgeComment(checkpoint);
3187
+ await this.postComment(comment);
3188
+ console.log("\n\u23F8\uFE0F Knowledge extraction posted to GitHub.");
3189
+ console.log(" Comment /knowledge-save or /knowledge-skip on the Issue/PR.");
3190
+ return { entries: [], skipped: false, pending: true };
3191
+ }
3192
+ formatKnowledgeComment(checkpoint) {
3193
+ const lines = [
3194
+ "## \u{1F4DA} Spets: Knowledge Extraction",
3195
+ "",
3196
+ `> Task ID: \`${this.taskId}\``,
3197
+ "",
3198
+ "The workflow is complete! Would you like to save any learnings for future workflows?",
3199
+ ""
3200
+ ];
3201
+ if (checkpoint.suggestedKnowledge.length > 0) {
3202
+ lines.push("### \u{1F4A1} Suggested Knowledge");
3203
+ lines.push("");
3204
+ for (const suggestion of checkpoint.suggestedKnowledge) {
3205
+ lines.push(`**${suggestion.filename}**`);
3206
+ lines.push(`> ${suggestion.reason}`);
3207
+ lines.push("");
3208
+ lines.push("<details>");
3209
+ lines.push("<summary>Preview content</summary>");
3210
+ lines.push("");
3211
+ lines.push(suggestion.content);
3212
+ lines.push("");
3213
+ lines.push("</details>");
3214
+ lines.push("");
3215
+ }
3216
+ } else {
3217
+ lines.push("No knowledge suggestions from this workflow.");
3218
+ lines.push("");
3219
+ }
3220
+ lines.push("---");
3221
+ lines.push("");
3222
+ lines.push("**Commands:**");
3223
+ lines.push("| Command | Description |");
3224
+ lines.push("|---------|-------------|");
3225
+ lines.push("| `/knowledge-save` | Save the suggested knowledge |");
3226
+ lines.push("| `/knowledge-skip` | Skip knowledge extraction |");
3227
+ lines.push("");
3228
+ lines.push("To save custom knowledge:");
3229
+ lines.push("```");
3230
+ lines.push("/knowledge-save");
3231
+ lines.push("filename1: your-knowledge-title");
3232
+ lines.push("content1: The knowledge content here");
3233
+ lines.push("```");
3234
+ return lines.join("\n");
3235
+ }
3100
3236
  formatQuestionsComment(questions) {
3101
3237
  const lines = [
3102
3238
  "## \u{1F4CB} Spets: Questions Need Answers",
@@ -4036,6 +4172,21 @@ async function startCommand(query, options) {
4036
4172
  } else {
4037
4173
  response = orchestrator.cmdStop(taskId);
4038
4174
  }
4175
+ } else if (response.checkpoint === "knowledge") {
4176
+ const knowledgeCheckpoint = response;
4177
+ console.log("\n\u{1F4DA} Knowledge Extraction\n");
4178
+ const result = await adapter.io.askKnowledge(knowledgeCheckpoint);
4179
+ if (result.pending) {
4180
+ console.log(`
4181
+ \u23F8\uFE0F Workflow paused. Task ID: ${taskId}`);
4182
+ console.log(" Resume with: spets resume --task", taskId);
4183
+ return;
4184
+ }
4185
+ if (result.skipped) {
4186
+ response = orchestrator.cmdKnowledgeSkip(taskId);
4187
+ } else {
4188
+ response = orchestrator.cmdKnowledgeSave(taskId, result.entries);
4189
+ }
4039
4190
  }
4040
4191
  } else {
4041
4192
  throw new Error(`Unknown response type: ${response.type}`);
@@ -4301,6 +4452,21 @@ async function resumeCommand(options) {
4301
4452
  } else {
4302
4453
  response = orchestrator.cmdStop(taskId);
4303
4454
  }
4455
+ } else if (response.checkpoint === "knowledge") {
4456
+ const knowledgeCheckpoint = response;
4457
+ console.log("\n\u{1F4DA} Knowledge Extraction\n");
4458
+ const result = await adapter.io.askKnowledge(knowledgeCheckpoint);
4459
+ if (result.pending) {
4460
+ console.log(`
4461
+ \u23F8\uFE0F Workflow paused. Task ID: ${taskId}`);
4462
+ console.log(" Resume with: spets resume --task", taskId);
4463
+ return;
4464
+ }
4465
+ if (result.skipped) {
4466
+ response = orchestrator.cmdKnowledgeSkip(taskId);
4467
+ } else {
4468
+ response = orchestrator.cmdKnowledgeSave(taskId, result.entries);
4469
+ }
4304
4470
  }
4305
4471
  } else {
4306
4472
  throw new Error(`Unknown response type: ${response.type}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spets",
3
- "version": "0.1.81",
3
+ "version": "0.1.82",
4
4
  "description": "Spec Driven Development Execution Framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",