@devkitvault/recall 1.2.3 → 1.2.4

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.askCommand = void 0;
7
7
  exports.printSuggestion = printSuggestion;
8
8
  exports.printAskError = printAskError;
9
+ exports.promptSaveMeta = promptSaveMeta;
9
10
  exports.saveSuggestion = saveSuggestion;
10
11
  exports.resolveAsk = resolveAsk;
11
12
  exports.runAsk = runAsk;
@@ -18,6 +19,7 @@ const events_1 = require("../lib/events");
18
19
  const project_1 = require("../lib/project");
19
20
  const runtime_1 = require("../lib/runtime");
20
21
  const spinner_1 = require("../lib/spinner");
22
+ const tags_1 = require("../lib/tags");
21
23
  function riskColor(risk) {
22
24
  if (risk === 'DANGEROUS')
23
25
  return chalk_1.default.red(risk);
@@ -67,12 +69,25 @@ function printAskError(err) {
67
69
  }
68
70
  console.error(chalk_1.default.red('\n Failed to resolve that request.\n'));
69
71
  }
70
- function parseTags(raw) {
71
- const tags = (raw ?? '')
72
- .split(',')
73
- .map((t) => t.trim())
74
- .filter(Boolean);
75
- return tags.length ? tags : undefined;
72
+ async function promptSaveMeta(existingName) {
73
+ const questions = [];
74
+ if (!existingName?.trim()) {
75
+ questions.push({
76
+ type: 'input',
77
+ name: 'name',
78
+ message: 'Name (optional):',
79
+ });
80
+ }
81
+ questions.push({
82
+ type: 'input',
83
+ name: 'tags',
84
+ message: 'Tags (optional):',
85
+ });
86
+ const answers = await inquirer_1.default.prompt(questions);
87
+ return {
88
+ name: existingName?.trim() || answers.name,
89
+ tags: (0, tags_1.parseTags)(answers.tags),
90
+ };
76
91
  }
77
92
  async function saveSuggestion(token, command, name, source, risk, tags) {
78
93
  await api_1.ApiClient.post('/commands', {
@@ -81,7 +96,7 @@ async function saveSuggestion(token, command, name, source, risk, tags) {
81
96
  tags,
82
97
  }, token);
83
98
  await (0, events_1.track)('ai_accepted', { source, risk, saved: true });
84
- console.log(chalk_1.default.green('\n Saved.\n'));
99
+ console.log(chalk_1.default.green(`\n ${(0, tags_1.formatSavedMessage)(name, tags)}\n`));
85
100
  }
86
101
  async function resolveAsk(opts) {
87
102
  const runtime = (0, runtime_1.detectRuntime)();
@@ -124,20 +139,9 @@ async function runAsk(query) {
124
139
  }]);
125
140
  if (!save)
126
141
  return;
127
- const { name, tags } = await inquirer_1.default.prompt([
128
- {
129
- type: 'input',
130
- name: 'name',
131
- message: 'Name (optional):',
132
- },
133
- {
134
- type: 'input',
135
- name: 'tags',
136
- message: 'Tags (optional):',
137
- },
138
- ]);
142
+ const { name, tags } = await promptSaveMeta();
139
143
  try {
140
- await saveSuggestion(token, result.command, name, result.source, result.risk, parseTags(tags));
144
+ await saveSuggestion(token, result.command, name, result.source, result.risk, tags);
141
145
  }
142
146
  catch (err) {
143
147
  printAskError(err);
@@ -12,7 +12,7 @@ const turns_1 = require("../lib/turns");
12
12
  const ask_1 = require("./ask");
13
13
  function printReplHelp() {
14
14
  console.log(chalk_1.default.dim(' Ask prints a command. It does not run it.'));
15
- console.log(chalk_1.default.dim(' /save [name] save the last suggestion'));
15
+ console.log(chalk_1.default.dim(' /save [name] save the last suggestion (asks for tags)'));
16
16
  console.log(chalk_1.default.dim(' /clear forget this session'));
17
17
  console.log(chalk_1.default.dim(' /exit leave'));
18
18
  }
@@ -54,9 +54,10 @@ async function runRepl() {
54
54
  console.log(chalk_1.default.dim(' nothing to save'));
55
55
  return;
56
56
  }
57
- const name = line === '/save' ? undefined : line.slice(6).trim();
57
+ const named = line === '/save' ? undefined : line.slice(6).trim();
58
58
  try {
59
- await (0, ask_1.saveSuggestion)(token, last.command, name, last.source, last.risk);
59
+ const { name, tags } = await (0, ask_1.promptSaveMeta)(named);
60
+ await (0, ask_1.saveSuggestion)(token, last.command, name, last.source, last.risk, tags);
60
61
  }
61
62
  catch {
62
63
  console.error(chalk_1.default.red('\n Failed to save.\n'));
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTags = parseTags;
4
+ exports.formatSavedMessage = formatSavedMessage;
5
+ function parseTags(raw) {
6
+ const tags = (raw ?? '')
7
+ .split(',')
8
+ .map((t) => t.trim())
9
+ .filter(Boolean);
10
+ return tags.length ? tags : undefined;
11
+ }
12
+ function formatSavedMessage(name, tags) {
13
+ const label = name?.trim() || undefined;
14
+ const tagPart = tags?.length ? ` [${tags.join(', ')}]` : '';
15
+ if (label)
16
+ return `Saved as "${label}"${tagPart}.`;
17
+ if (tagPart)
18
+ return `Saved${tagPart}.`;
19
+ return 'Saved.';
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkitvault/recall",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "recall CLI — AI terminal copilot with a personal command vault",
5
5
  "keywords": [
6
6
  "cli",