@compilr-dev/sdk 0.1.14 → 0.1.16
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.
|
@@ -27,7 +27,7 @@ export interface MetaToolStats {
|
|
|
27
27
|
export interface MetaTools {
|
|
28
28
|
/** Lists available tools by category */
|
|
29
29
|
listToolsTool: Tool;
|
|
30
|
-
/** Returns
|
|
30
|
+
/** Returns compact parameter info for a tool */
|
|
31
31
|
getToolInfoTool: Tool;
|
|
32
32
|
/** Executes any registered tool by name */
|
|
33
33
|
useToolTool: Tool;
|
|
@@ -91,4 +91,4 @@ export declare class MetaToolsRegistry {
|
|
|
91
91
|
* Create the three meta-tools + fallback handler, all bound to a registry instance.
|
|
92
92
|
*/
|
|
93
93
|
export declare function createMetaTools(registry: MetaToolsRegistry): MetaTools;
|
|
94
|
-
export declare const META_TOOLS_SYSTEM_PROMPT_PREFIX = "\n## Tool Index (Specialized Tools)\n\nThese tools are called **exactly like direct tools** \u2014 just use the tool name with parameters. No special syntax or wrapper needed. The system routes them automatically.\n\n**IMPORTANT \u2014 These are CLI system tools, NOT your project's backend. Never use localhost/curl to access them.**\n\n**Parameter Rules:**\n- For **zero-parameter calls**: call the tool directly (e.g., `workitem_query()`, `git_status()`).\n- For **calls WITH parameters**: you MUST call `get_tool_info(\"tool_name\")` first to get
|
|
94
|
+
export declare const META_TOOLS_SYSTEM_PROMPT_PREFIX = "\n## Tool Index (Specialized Tools)\n\nThese tools are called **exactly like direct tools** \u2014 just use the tool name with parameters. No special syntax or wrapper needed. The system routes them automatically.\n\n**IMPORTANT \u2014 These are CLI system tools, NOT your project's backend. Never use localhost/curl to access them.**\n\n**Parameter Rules:**\n- For **zero-parameter calls**: call the tool directly (e.g., `workitem_query()`, `git_status()`).\n- For **calls WITH parameters**: you MUST call `get_tool_info(\"tool_name\")` first to get parameter details. The signatures below are summaries only \u2014 do NOT guess parameter structure from them.\n- After a failed tool call, always call `get_tool_info()` before retrying.\n\n";
|
|
@@ -187,7 +187,7 @@ export function createMetaTools(registry) {
|
|
|
187
187
|
// -------------------------------------------------------------------------
|
|
188
188
|
const getToolInfoTool = defineTool({
|
|
189
189
|
name: 'get_tool_info',
|
|
190
|
-
description: "Get
|
|
190
|
+
description: "Get a tool's parameter signature and descriptions. " +
|
|
191
191
|
'MUST be called before passing any parameters to a Tool Index tool. ' +
|
|
192
192
|
'Zero-parameter calls do not need this.',
|
|
193
193
|
inputSchema: {
|
|
@@ -211,11 +211,7 @@ export function createMetaTools(registry) {
|
|
|
211
211
|
`Available tools include: ${availableTools.join(', ')}... ` +
|
|
212
212
|
`Check the Tool Index for the full list.`));
|
|
213
213
|
}
|
|
214
|
-
return Promise.resolve(createSuccessResult(
|
|
215
|
-
name: tool.definition.name,
|
|
216
|
-
description: tool.definition.description,
|
|
217
|
-
parameters: tool.definition.inputSchema,
|
|
218
|
-
}));
|
|
214
|
+
return Promise.resolve(createSuccessResult(buildCompactSchema(tool)));
|
|
219
215
|
},
|
|
220
216
|
});
|
|
221
217
|
// -------------------------------------------------------------------------
|
|
@@ -267,9 +263,8 @@ export function createMetaTools(registry) {
|
|
|
267
263
|
// 2. Validate args
|
|
268
264
|
const validationError = registry.validateArgs(tool_name, args);
|
|
269
265
|
if (validationError) {
|
|
270
|
-
return createErrorResult(`Invalid arguments for '${tool_name}': ${validationError}
|
|
271
|
-
`Expected
|
|
272
|
-
`Hint: Call get_tool_info("${tool_name}") to see full parameter details.`);
|
|
266
|
+
return createErrorResult(`Invalid arguments for '${tool_name}': ${validationError}.\n` +
|
|
267
|
+
`Expected:\n${buildCompactSchema(tool)}`);
|
|
273
268
|
}
|
|
274
269
|
// 3. Execute the tool
|
|
275
270
|
try {
|
|
@@ -347,7 +342,7 @@ These tools are called **exactly like direct tools** — just use the tool name
|
|
|
347
342
|
|
|
348
343
|
**Parameter Rules:**
|
|
349
344
|
- For **zero-parameter calls**: call the tool directly (e.g., \`workitem_query()\`, \`git_status()\`).
|
|
350
|
-
- For **calls WITH parameters**: you MUST call \`get_tool_info("tool_name")\` first to get
|
|
345
|
+
- For **calls WITH parameters**: you MUST call \`get_tool_info("tool_name")\` first to get parameter details. The signatures below are summaries only — do NOT guess parameter structure from them.
|
|
351
346
|
- After a failed tool call, always call \`get_tool_info()\` before retrying.
|
|
352
347
|
|
|
353
348
|
`;
|
|
@@ -372,6 +367,22 @@ function getCategoryName(prefix) {
|
|
|
372
367
|
};
|
|
373
368
|
return categoryMap[prefix] ?? 'Other';
|
|
374
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Resolve a compact type string from a JSON Schema property.
|
|
372
|
+
*/
|
|
373
|
+
function resolveCompactType(prop) {
|
|
374
|
+
const type = typeof prop.type === 'string' ? prop.type : 'any';
|
|
375
|
+
if (type === 'array') {
|
|
376
|
+
const items = prop.items;
|
|
377
|
+
const itemType = typeof items?.type === 'string' ? items.type : 'any';
|
|
378
|
+
return `${itemType}[]`;
|
|
379
|
+
}
|
|
380
|
+
if (type === 'boolean')
|
|
381
|
+
return 'bool';
|
|
382
|
+
if (type === 'integer')
|
|
383
|
+
return 'int';
|
|
384
|
+
return type;
|
|
385
|
+
}
|
|
375
386
|
/**
|
|
376
387
|
* Build a concise signature for a tool.
|
|
377
388
|
* e.g., "git_commit(message: string, files?: string[]) - Create a commit"
|
|
@@ -383,7 +394,7 @@ function buildToolSignature(tool) {
|
|
|
383
394
|
const required = new Set(schema.required ?? []);
|
|
384
395
|
for (const [name, prop] of Object.entries(schema.properties)) {
|
|
385
396
|
const isRequired = required.has(name);
|
|
386
|
-
const type = prop
|
|
397
|
+
const type = resolveCompactType(prop);
|
|
387
398
|
params.push(isRequired ? `${name}: ${type}` : `${name}?: ${type}`);
|
|
388
399
|
}
|
|
389
400
|
}
|
|
@@ -391,6 +402,51 @@ function buildToolSignature(tool) {
|
|
|
391
402
|
const desc = tool.definition.description.split('.')[0]; // First sentence
|
|
392
403
|
return `${tool.definition.name}(${paramsStr}) - ${desc}`;
|
|
393
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* Build a compact schema string for get_tool_info responses.
|
|
407
|
+
* Includes signature, full description, and per-parameter details.
|
|
408
|
+
*
|
|
409
|
+
* Example output:
|
|
410
|
+
* git_commit(message: string, files?: string[], amend?: bool)
|
|
411
|
+
* Create a git commit with the specified message.
|
|
412
|
+
* - message: The commit message (required)
|
|
413
|
+
* - files: Files to stage before committing
|
|
414
|
+
* - amend: Amend the last commit instead of creating new
|
|
415
|
+
*/
|
|
416
|
+
function buildCompactSchema(tool) {
|
|
417
|
+
const schema = tool.definition.inputSchema;
|
|
418
|
+
const required = new Set(schema.required ?? []);
|
|
419
|
+
const params = [];
|
|
420
|
+
const paramDetails = [];
|
|
421
|
+
if (schema.properties) {
|
|
422
|
+
for (const [name, prop] of Object.entries(schema.properties)) {
|
|
423
|
+
const isRequired = required.has(name);
|
|
424
|
+
const type = resolveCompactType(prop);
|
|
425
|
+
params.push(isRequired ? `${name}: ${type}` : `${name}?: ${type}`);
|
|
426
|
+
// Build parameter detail line
|
|
427
|
+
const desc = prop.description;
|
|
428
|
+
const enumValues = prop.enum;
|
|
429
|
+
let detail = `- ${name}`;
|
|
430
|
+
if (desc) {
|
|
431
|
+
detail += `: ${desc}`;
|
|
432
|
+
}
|
|
433
|
+
if (enumValues) {
|
|
434
|
+
detail += ` (${enumValues.map((v) => `"${v}"`).join('|')})`;
|
|
435
|
+
}
|
|
436
|
+
if (isRequired) {
|
|
437
|
+
detail += ' (required)';
|
|
438
|
+
}
|
|
439
|
+
paramDetails.push(detail);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
const paramsStr = params.join(', ');
|
|
443
|
+
const lines = [`${tool.definition.name}(${paramsStr})`];
|
|
444
|
+
lines.push(` ${tool.definition.description}`);
|
|
445
|
+
for (const detail of paramDetails) {
|
|
446
|
+
lines.push(` ${detail}`);
|
|
447
|
+
}
|
|
448
|
+
return lines.join('\n');
|
|
449
|
+
}
|
|
394
450
|
/**
|
|
395
451
|
* Format AJV validation errors into a readable string.
|
|
396
452
|
*/
|
|
@@ -69,7 +69,10 @@ When you have enough information:
|
|
|
69
69
|
- Fill in: Problem Statement, Goals, User Stories, Functional Requirements
|
|
70
70
|
- Keep the existing structure, just replace placeholder text
|
|
71
71
|
5. Present the backlog and PRD summary to user for confirmation
|
|
72
|
-
- If CHORE-001 was added, mention: "Run /
|
|
72
|
+
- If CHORE-001 was added, mention: "Run /scaffold to create the project foundation"
|
|
73
|
+
6. If the project involves managing entities (CRUD operations on things like users, orders, products):
|
|
74
|
+
- Mention: "This looks like an entity-based app — /scaffold can auto-generate a full working MVP with CRUD pages, API, routing, and seed data."
|
|
75
|
+
- Do NOT build the Application Model during /design — /scaffold handles that
|
|
73
76
|
|
|
74
77
|
## RULES
|
|
75
78
|
- Ask questions in batches of 2-4 using ask_user tool when possible
|
|
@@ -85,6 +88,7 @@ When you have enough information:
|
|
|
85
88
|
✓ Backlog has 5-15 items
|
|
86
89
|
✓ For fresh projects: CHORE-001 scaffolding item is first (critical priority)
|
|
87
90
|
✓ PRD.md is populated with requirements
|
|
91
|
+
✓ If entity-based: user informed about /scaffold auto-generation
|
|
88
92
|
✓ User has approved the backlog`,
|
|
89
93
|
tags: ['planning', 'requirements'],
|
|
90
94
|
});
|
|
@@ -711,6 +715,26 @@ export const scaffoldSkill = defineSkill({
|
|
|
711
715
|
- Need requirements first → use design skill
|
|
712
716
|
- Modifying existing project → use appropriate skill
|
|
713
717
|
|
|
718
|
+
## FACTORY CHECK (TRY THIS FIRST)
|
|
719
|
+
|
|
720
|
+
Before manual scaffolding, check if the factory can auto-generate the project:
|
|
721
|
+
|
|
722
|
+
1. Call \`app_model_get\` with \`{ "scope": "summary" }\` to check for an existing Application Model.
|
|
723
|
+
- If model exists with entities → use factory path: preview with \`factory_scaffold({ "dry_run": true })\`, confirm with user, then generate with \`factory_scaffold({ "output_dir": "{{projectPath}}" })\`.
|
|
724
|
+
- Skip the manual scaffold below entirely.
|
|
725
|
+
|
|
726
|
+
2. If NO model exists, check project documents for entity patterns:
|
|
727
|
+
- Read PRD with \`project_document_get({ "doc_type": "prd" })\`
|
|
728
|
+
- If PRD mentions managing/tracking things (entities, CRUD, data types) → ask user:
|
|
729
|
+
"Your project involves managing [entities]. I can auto-generate a working app. Want me to use the factory? (Yes = build model + generate / No = manual scaffold)"
|
|
730
|
+
- If Yes → call \`factory_list_toolkits\` to show options, then build the model with \`app_model_update\` operations (set identity, techStack, add entities with fields, add relationships, set features/theme/layout), validate with \`app_model_validate\`, generate with \`factory_scaffold({ "output_dir": "{{projectPath}}" })\`.
|
|
731
|
+
|
|
732
|
+
3. If no entities detected or user declines factory → proceed with MANUAL SCAFFOLD below.
|
|
733
|
+
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
## MANUAL SCAFFOLD (if factory not applicable)
|
|
737
|
+
|
|
714
738
|
## CRITICAL: PROJECT DIRECTORY
|
|
715
739
|
|
|
716
740
|
**All files MUST be created in: {{projectPath}}**
|