@hanhnd/agent-kit 1.0.19 → 1.0.20
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/kit-server.js +15 -5
- package/dist/tools/core.js +17 -5
- package/package.json +1 -1
package/dist/kit-server.js
CHANGED
|
@@ -21051,20 +21051,30 @@ function registerCoreTools(server2) {
|
|
|
21051
21051
|
"kit_save_handoff",
|
|
21052
21052
|
"Save a brainstorm, plan, or ticket handoff artifact to .agent-kit/handoffs/. Returns the saved file path to use in next-step instructions.",
|
|
21053
21053
|
{
|
|
21054
|
-
type: external_exports.enum(["brainstorm", "plan", "ticket"]).describe("Handoff type"),
|
|
21054
|
+
type: external_exports.enum(["brainstorm", "plan", "ticket", "research"]).describe("Handoff type"),
|
|
21055
21055
|
content: external_exports.string().describe("Full markdown content to save"),
|
|
21056
|
-
slug: external_exports.string().describe(
|
|
21056
|
+
slug: external_exports.string().describe(
|
|
21057
|
+
'Short identifier for the filename, e.g. "user-auth" or "PROJ-123". Do NOT append version numbers (v2, v3, etc); the tool will automatically update the existing file if it exists.'
|
|
21058
|
+
)
|
|
21057
21059
|
},
|
|
21058
21060
|
async ({ type, content, slug }) => {
|
|
21059
21061
|
try {
|
|
21060
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
21061
21062
|
const safeSlug = slug.replace(/[^a-zA-Z0-9-_]/g, "-").toLowerCase();
|
|
21062
|
-
const filename = `${type}-${timestamp}-${safeSlug}.md`;
|
|
21063
21063
|
const handoffDir = path.join(getWorkspaceRoot(), ".agent-kit", "handoffs", `${type}s`);
|
|
21064
21064
|
if (!fs.existsSync(handoffDir)) {
|
|
21065
21065
|
fs.mkdirSync(handoffDir, { recursive: true });
|
|
21066
21066
|
}
|
|
21067
|
-
const
|
|
21067
|
+
const files = fs.readdirSync(handoffDir);
|
|
21068
|
+
const slugPattern = new RegExp(`^${type}-([0-9T-]{19}-)?${safeSlug}\\.md$`);
|
|
21069
|
+
const existingFile = files.filter((f) => slugPattern.test(f)).sort().pop();
|
|
21070
|
+
let filePath;
|
|
21071
|
+
if (existingFile) {
|
|
21072
|
+
filePath = path.join(handoffDir, existingFile);
|
|
21073
|
+
} else {
|
|
21074
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
21075
|
+
const filename = `${type}-${timestamp}-${safeSlug}.md`;
|
|
21076
|
+
filePath = path.join(handoffDir, filename);
|
|
21077
|
+
}
|
|
21068
21078
|
fs.writeFileSync(filePath, content, "utf8");
|
|
21069
21079
|
return mcpText(`\u2705 Saved to: ${filePath}`);
|
|
21070
21080
|
} catch (error2) {
|
package/dist/tools/core.js
CHANGED
|
@@ -16,21 +16,33 @@ export function registerCoreTools(server) {
|
|
|
16
16
|
// Returns the saved file path for use in next-step instructions
|
|
17
17
|
// ═══════════════════════════════════════════════════════════════
|
|
18
18
|
server.tool('kit_save_handoff', 'Save a brainstorm, plan, or ticket handoff artifact to .agent-kit/handoffs/. Returns the saved file path to use in next-step instructions.', {
|
|
19
|
-
type: z.enum(['brainstorm', 'plan', 'ticket']).describe('Handoff type'),
|
|
19
|
+
type: z.enum(['brainstorm', 'plan', 'ticket', 'research']).describe('Handoff type'),
|
|
20
20
|
content: z.string().describe('Full markdown content to save'),
|
|
21
21
|
slug: z
|
|
22
22
|
.string()
|
|
23
|
-
.describe('Short identifier for the filename, e.g. "user-auth" or "PROJ-123"'),
|
|
23
|
+
.describe('Short identifier for the filename, e.g. "user-auth" or "PROJ-123". Do NOT append version numbers (v2, v3, etc); the tool will automatically update the existing file if it exists.'),
|
|
24
24
|
}, async ({ type, content, slug }) => {
|
|
25
25
|
try {
|
|
26
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
27
26
|
const safeSlug = slug.replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();
|
|
28
|
-
const filename = `${type}-${timestamp}-${safeSlug}.md`;
|
|
29
27
|
const handoffDir = path.join(getWorkspaceRoot(), '.agent-kit', 'handoffs', `${type}s`);
|
|
30
28
|
if (!fs.existsSync(handoffDir)) {
|
|
31
29
|
fs.mkdirSync(handoffDir, { recursive: true });
|
|
32
30
|
}
|
|
33
|
-
const
|
|
31
|
+
const files = fs.readdirSync(handoffDir);
|
|
32
|
+
const slugPattern = new RegExp(`^${type}-([0-9T-]{19}-)?${safeSlug}\\.md$`);
|
|
33
|
+
const existingFile = files
|
|
34
|
+
.filter((f) => slugPattern.test(f))
|
|
35
|
+
.sort()
|
|
36
|
+
.pop();
|
|
37
|
+
let filePath;
|
|
38
|
+
if (existingFile) {
|
|
39
|
+
filePath = path.join(handoffDir, existingFile);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
43
|
+
const filename = `${type}-${timestamp}-${safeSlug}.md`;
|
|
44
|
+
filePath = path.join(handoffDir, filename);
|
|
45
|
+
}
|
|
34
46
|
fs.writeFileSync(filePath, content, 'utf8');
|
|
35
47
|
return mcpText(`✅ Saved to: ${filePath}`);
|
|
36
48
|
}
|