@compilr-dev/sdk 0.26.0 → 0.28.0

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 (74) hide show
  1. package/dist/actions/registry.d.ts +1 -1
  2. package/dist/actions/registry.js +1 -1
  3. package/dist/guide/shared-content.js +42 -9
  4. package/dist/index.d.ts +12 -8
  5. package/dist/index.js +7 -5
  6. package/dist/platform/tools/canvas-tools.js +11 -11
  7. package/dist/project-types/action-meta.d.ts +21 -7
  8. package/dist/project-types/action-meta.js +44 -213
  9. package/dist/project-types/index.d.ts +5 -3
  10. package/dist/project-types/index.js +3 -2
  11. package/dist/project-types/macro-meta.d.ts +39 -0
  12. package/dist/project-types/{skill-meta.js → macro-meta.js} +203 -12
  13. package/dist/project-types/macro-relevance.d.ts +47 -0
  14. package/dist/project-types/macro-relevance.js +58 -0
  15. package/dist/project-types/types.d.ts +23 -4
  16. package/dist/skills/book-macros.d.ts +10 -0
  17. package/dist/skills/{book-skills.js → book-macros.js} +6 -6
  18. package/dist/skills/business-macros.d.ts +11 -0
  19. package/dist/skills/{business-skills.js → business-macros.js} +7 -7
  20. package/dist/skills/canvas-exemplars.d.ts +2 -2
  21. package/dist/skills/canvas-exemplars.js +4 -4
  22. package/dist/skills/canvas-icons.d.ts +1 -1
  23. package/dist/skills/canvas-icons.js +2 -2
  24. package/dist/skills/canvas-macros.d.ts +11 -0
  25. package/dist/skills/{canvas-skills.js → canvas-macros.js} +11 -11
  26. package/dist/skills/content-macros.d.ts +10 -0
  27. package/dist/skills/{content-skills.js → content-macros.js} +6 -6
  28. package/dist/skills/course-macros.d.ts +9 -0
  29. package/dist/skills/{course-skills.js → course-macros.js} +5 -5
  30. package/dist/skills/index.d.ts +6 -2
  31. package/dist/skills/index.js +4 -2
  32. package/dist/skills/macro-invocation.d.ts +78 -0
  33. package/dist/skills/macro-invocation.js +286 -0
  34. package/dist/skills/macro-list.d.ts +54 -0
  35. package/dist/skills/macro-list.js +84 -0
  36. package/dist/skills/operations.js +4 -4
  37. package/dist/skills/platform-macros.d.ts +27 -0
  38. package/dist/skills/platform-macros.js +94 -0
  39. package/dist/skills/prompt-resolver.d.ts +8 -2
  40. package/dist/skills/prompt-resolver.js +14 -8
  41. package/dist/skills/research-macros.d.ts +10 -0
  42. package/dist/skills/{research-skills.js → research-macros.js} +6 -6
  43. package/dist/skills/resolver.d.ts +15 -9
  44. package/dist/skills/resolver.js +13 -13
  45. package/dist/skills/software-macros.d.ts +14 -0
  46. package/dist/skills/{software-skills.js → software-macros.js} +37 -37
  47. package/dist/skills/types.d.ts +2 -2
  48. package/dist/skills/types.js +4 -4
  49. package/dist/team/agent-templates.d.ts +0 -1
  50. package/dist/team/agent-templates.js +0 -2
  51. package/dist/team/custom-agents.d.ts +1 -2
  52. package/dist/team/custom-agents.js +1 -2
  53. package/dist/team/index.d.ts +3 -3
  54. package/dist/team/index.js +1 -1
  55. package/dist/team/{skill-requirements.d.ts → macro-requirements.d.ts} +20 -14
  56. package/dist/team/{skill-requirements.js → macro-requirements.js} +28 -22
  57. package/dist/team/macro-tool-gap.d.ts +3 -3
  58. package/dist/team/macro-tool-gap.js +6 -6
  59. package/dist/team/team-agent.d.ts +6 -7
  60. package/dist/team/team-agent.js +6 -14
  61. package/dist/team/types.d.ts +8 -7
  62. package/dist/team/workshop-data.d.ts +17 -5
  63. package/dist/team/workshop-data.js +13 -13
  64. package/package.json +1 -1
  65. package/dist/project-types/skill-meta.d.ts +0 -17
  66. package/dist/skills/book-skills.d.ts +0 -10
  67. package/dist/skills/business-skills.d.ts +0 -11
  68. package/dist/skills/canvas-skills.d.ts +0 -11
  69. package/dist/skills/content-skills.d.ts +0 -10
  70. package/dist/skills/course-skills.d.ts +0 -9
  71. package/dist/skills/platform-skills.d.ts +0 -20
  72. package/dist/skills/platform-skills.js +0 -87
  73. package/dist/skills/research-skills.d.ts +0 -10
  74. package/dist/skills/software-skills.d.ts +0 -14
@@ -0,0 +1,78 @@
1
+ /**
2
+ * What a host actually SENDS when a user invokes a macro.
3
+ *
4
+ * ⚠️ THE TWO HOSTS SENT DIFFERENT THINGS FOR THE SAME COMMAND. The CLI wrapped each of these
5
+ * macros in project context — do not scan the filesystem, the cwd is not the project, save work
6
+ * items with `workitem_add` and documents with `project_document_add` rather than writing files —
7
+ * while Desktop sent the prompt alone. Same names, same macros, materially different
8
+ * instructions, so the same request produced an agent that interviewed you and filled the backlog
9
+ * in one host and an agent that went looking for source files in the other.
10
+ *
11
+ * The prompts were always shared data; what surrounded them was not. It is now.
12
+ *
13
+ * ⚠️ THE TEXT IS TRANSCRIBED, NOT REWRITTEN. Every block below was generated from the CLI's own
14
+ * template and asserted byte-identical to what it sent before the move, because a single reworded
15
+ * line here is a silent behaviour change in both hosts at once.
16
+ *
17
+ * This composes the MESSAGE only. The tool-gap preamble (`macroToolGap`) stays a separate,
18
+ * host-applied prepend: it depends on which AGENT is addressed, which only the host knows.
19
+ */
20
+ /** What the host knows about the project a macro is invoked against. */
21
+ export interface MacroProjectContext {
22
+ id: string | number;
23
+ name: string;
24
+ /** Absolute path on disk. `build` and `scaffold` write files and need it. */
25
+ path?: string;
26
+ }
27
+ /** A backlog item, for `build`. */
28
+ export interface MacroWorkItem {
29
+ itemId: string;
30
+ type: string;
31
+ priority: string;
32
+ title: string;
33
+ description?: string;
34
+ }
35
+ export interface MacroInvocationContext {
36
+ /** Absent when no project is selected; the context block is then omitted entirely. */
37
+ project?: MacroProjectContext;
38
+ /** `prd` — the section the user named, if any. */
39
+ section?: string;
40
+ /** `session-notes` — the title the user gave, if any. */
41
+ noteTitle?: string;
42
+ /** `architecture` — the document type chosen, and how to name it back to the user. */
43
+ architecture?: {
44
+ docType: string;
45
+ displayType?: string;
46
+ };
47
+ /** `refine` — the item id, when refining one item rather than the whole backlog. */
48
+ refineItemId?: string;
49
+ /** `build` — the item to implement. Without it there is nothing to build. */
50
+ workItem?: MacroWorkItem;
51
+ /**
52
+ * `scaffold` — `factoryContext` is a pre-rendered block the host supplies because only it
53
+ * knows the Application Model's state; `isFactory` picks the closing instruction.
54
+ */
55
+ scaffold?: {
56
+ factoryContext?: string;
57
+ isFactory?: boolean;
58
+ };
59
+ }
60
+ export interface MacroInvocation {
61
+ /** The text to send to the agent. */
62
+ message: string;
63
+ /** The short line to show the user in place of the full message. */
64
+ displayMessage: string;
65
+ }
66
+ /**
67
+ * Compose the message for a macro invocation.
68
+ *
69
+ * A macro with no wrapper sends its prompt unchanged — the common case, and the default, so
70
+ * adding a macro needs no edit here. A macro WITH a wrapper falls back to the bare prompt when
71
+ * the host cannot supply what the wrapper names: better a plain prompt than one asserting a
72
+ * project, an item or a path that is not there.
73
+ *
74
+ * @param macroName the macro being invoked, e.g. `design`
75
+ * @param prompt the macro's resolved prompt text
76
+ * @param ctx what the host knows
77
+ */
78
+ export declare function buildMacroInvocation(macroName: string, prompt: string, ctx?: MacroInvocationContext): MacroInvocation;
@@ -0,0 +1,286 @@
1
+ /**
2
+ * What a host actually SENDS when a user invokes a macro.
3
+ *
4
+ * ⚠️ THE TWO HOSTS SENT DIFFERENT THINGS FOR THE SAME COMMAND. The CLI wrapped each of these
5
+ * macros in project context — do not scan the filesystem, the cwd is not the project, save work
6
+ * items with `workitem_add` and documents with `project_document_add` rather than writing files —
7
+ * while Desktop sent the prompt alone. Same names, same macros, materially different
8
+ * instructions, so the same request produced an agent that interviewed you and filled the backlog
9
+ * in one host and an agent that went looking for source files in the other.
10
+ *
11
+ * The prompts were always shared data; what surrounded them was not. It is now.
12
+ *
13
+ * ⚠️ THE TEXT IS TRANSCRIBED, NOT REWRITTEN. Every block below was generated from the CLI's own
14
+ * template and asserted byte-identical to what it sent before the move, because a single reworded
15
+ * line here is a silent behaviour change in both hosts at once.
16
+ *
17
+ * This composes the MESSAGE only. The tool-gap preamble (`macroToolGap`) stays a separate,
18
+ * host-applied prepend: it depends on which AGENT is addressed, which only the host knows.
19
+ */
20
+ function designContext(project) {
21
+ return `I want to design my project and create the backlog.
22
+
23
+ ## PROJECT CONTEXT (IMPORTANT)
24
+ - Project Name: ${project.name} (ID: ${String(project.id)})
25
+ - This is a NEW project being designed from scratch
26
+ - Do NOT scan the filesystem - the current directory is NOT the project
27
+ - Do NOT use detect_project, glob, read_file, or ls tools
28
+ - Focus ONLY on gathering requirements via ask_user questions
29
+
30
+ ## DOCUMENT STORAGE (CRITICAL)
31
+ Save all documents and backlog items using the database - do NOT write files directly.
32
+ - For backlog items: \`workitem_add({ type: "feature", title: "...", description: "...", priority: "high" })\`
33
+ - For documents: \`project_document_add({ doc_type: "prd", title: "...", content: "..." })\`
34
+ - The database is the source of truth for all project documents
35
+ - Do NOT use write_file or edit tools for documentation
36
+ `;
37
+ }
38
+ const DESIGN_CLOSER = 'Please start by using todo_write to track the design phases, then begin with Phase 1: Vision. ' +
39
+ 'Use the ask_user tool to gather information efficiently.';
40
+ function sketchMessage(p, prompt) {
41
+ return `I want to quickly outline my project.
42
+
43
+ ## PROJECT CONTEXT (IMPORTANT)
44
+ - Project Name: ${p.name} (ID: ${String(p.id)})
45
+ - This is a NEW project being designed from scratch
46
+ - Do NOT scan the filesystem - the current directory is NOT the project
47
+ - Do NOT use detect_project, glob, read_file, or ls tools
48
+ - Focus ONLY on gathering requirements via ask_user questions
49
+
50
+ ## DOCUMENT STORAGE (CRITICAL)
51
+ Save all documents and backlog items using the database - do NOT write files directly.
52
+ - For backlog items: \`workitem_add({ type: "feature", title: "...", description: "..." })\`
53
+ - For documents: \`project_document_add({ doc_type: "prd", title: "...", content: "..." })\`
54
+ - Do NOT use write_file or edit tools for documentation
55
+
56
+ ${prompt}
57
+
58
+ Please start by asking me about the type of application I'm building using the ask_user_simple tool.`;
59
+ }
60
+ function refineMessage(p, prompt, userIntent, agentInstructions) {
61
+ return `${userIntent}
62
+
63
+ ## PROJECT CONTEXT (IMPORTANT)
64
+ - Project Name: ${p.name} (ID: ${String(p.id)})
65
+ - Do NOT scan the filesystem - the current directory is NOT the project
66
+ - Do NOT use detect_project, glob, read_file, or ls tools
67
+ - Use ONLY database tools to access project data
68
+
69
+ ## DOCUMENT STORAGE (CRITICAL)
70
+ Use database tools for all updates - do NOT write files directly.
71
+ - Use \`workitem_query\` to read items
72
+ - Use \`workitem_update\` to modify items
73
+ - Do NOT use write_file or edit tools
74
+
75
+ ${prompt}
76
+
77
+ ${agentInstructions}`;
78
+ }
79
+ function buildMessage(p, prompt, item) {
80
+ return `I want to implement backlog item ${item.itemId}: "${item.title}".
81
+
82
+ ## PROJECT CONTEXT (CRITICAL)
83
+ - Project Name: ${p.name} (ID: ${String(p.id)})
84
+ - **Project Directory: ${p.path ?? ''}**
85
+ - ALL files MUST be created/modified in this directory
86
+
87
+ ## WORK ITEM DETAILS
88
+ - Item ID: ${item.itemId}
89
+ - Type: ${item.type}
90
+ - Priority: ${item.priority}
91
+ - Description: ${item.description ?? 'No description provided'}
92
+
93
+ ## TOOL RESTRICTIONS (CRITICAL)
94
+ - Do NOT use detect_project or find_project_root
95
+ - Do NOT scan filesystem to detect project type
96
+ - The project path above is the ONLY source of truth for where to create/modify files
97
+ - Use \`project_document_get\` to read PRD and architecture docs from the database
98
+ - Use \`workitem_query\` to read related backlog items from the database
99
+ - Use \`workitem_update\` to update the item status when done
100
+
101
+ ## FILE OPERATIONS (CRITICAL)
102
+ When creating or modifying files:
103
+ - Use absolute paths starting with: ${p.path ?? ''}/
104
+ - Example: write_file({ path: "${p.path ?? ''}/src/index.ts", ... })
105
+ - NEVER use relative paths
106
+ - IGNORE the current working directory (cwd) - it may be different from the project!
107
+ - The user may have started the CLI from a different folder
108
+
109
+ ${prompt}
110
+
111
+ Please start by:
112
+ 1. Using todo_write to plan the implementation steps
113
+ 2. Reading project documents from the database (project_document_list, project_document_get)
114
+ 3. Updating the work item status to 'in_progress' using workitem_update
115
+ 4. Implementing the feature
116
+ 5. Updating the work item status to 'completed' when done`;
117
+ }
118
+ function sessionNotesMessage(p, prompt, titleInstruction) {
119
+ return `I want to create a session note capturing what we've done.
120
+
121
+ ## PROJECT CONTEXT
122
+ - Project Name: ${p.name} (ID: ${String(p.id)})
123
+
124
+ ## DOCUMENT STORAGE (CRITICAL)
125
+ Save session notes using the database - do NOT write files directly.
126
+ - Tool: \`project_document_add({ doc_type: "session-note", title: "...", content: "..." })\`
127
+ - The database is the source of truth for all project documents
128
+ - Do NOT use write_file or edit tools for documentation
129
+
130
+ ${prompt}
131
+
132
+ ${titleInstruction}
133
+
134
+ Review the conversation context to understand what was accomplished, then create the session note.`;
135
+ }
136
+ function prdMessage(p, prompt, sectionInstruction) {
137
+ return `I want to update the Product Requirements Document.
138
+
139
+ ## DOCUMENT STORAGE (CRITICAL)
140
+ Save PRD updates using the database - do NOT write files directly.
141
+ - Project: ${p.name} (ID: ${String(p.id)})
142
+ - Tool: \`project_document_add({ doc_type: "prd", title: "Product Requirements Document", content: "..." })\`
143
+ - The database is the source of truth for all project documents
144
+ - Do NOT use write_file or edit tools for documentation
145
+
146
+ ${prompt}
147
+
148
+ ${sectionInstruction}
149
+
150
+ Start by reading the existing PRD from the database using project_document_get({ doc_type: "prd" }). If no document exists yet, create a new one.`;
151
+ }
152
+ function architectureMessage(p, prompt, arch) {
153
+ return `I want to create architecture documentation.
154
+
155
+ ## DOCUMENT STORAGE (CRITICAL)
156
+ Save architecture documentation using the database - do NOT write files directly.
157
+ - Project: ${p.name} (ID: ${String(p.id)})
158
+ - Tool: \`project_document_add({ doc_type: "architecture", title: "...", content: "..." })\`
159
+ - The database is the source of truth for all project documents
160
+ - Do NOT use write_file or edit tools for documentation
161
+
162
+ ${prompt}
163
+
164
+ Please start by using project_document_list to find any existing PRD, and workitem_query to understand the project backlog. Then use ask_user to gather the information needed for this ${arch.docType} document.`;
165
+ }
166
+ function scaffoldMessage(p, prompt, factoryContext, closingInstruction) {
167
+ return `I want to create the project scaffold/foundation.
168
+
169
+ ## PROJECT CONTEXT (CRITICAL)
170
+ - Project Name: ${p.name} (ID: ${String(p.id)})
171
+ - **Project Directory: ${p.path ?? ''}**
172
+ - ALL files MUST be created in this directory
173
+ ${factoryContext}
174
+ ## TOOL RESTRICTIONS (CRITICAL)
175
+ - Do NOT use detect_project or find_project_root
176
+ - Do NOT scan filesystem to detect project type
177
+ - The project path above is the ONLY source of truth for where to create files
178
+ - Use \`project_document_get\` to read PRD and architecture docs from the database
179
+ - Use \`workitem_query\` to read backlog items from the database
180
+
181
+ ## FILE CREATION (CRITICAL)
182
+ When creating files:
183
+ - Use absolute paths starting with: ${p.path ?? ''}/
184
+ - Example: write_file({ path: "${p.path ?? ''}/package.json", ... })
185
+ - NEVER use relative paths
186
+ - IGNORE the current working directory (cwd) - it may be different from the project!
187
+ - The user may have started the CLI from a different folder
188
+
189
+ ${prompt}
190
+
191
+ ${closingInstruction}`;
192
+ }
193
+ /**
194
+ * Compose the message for a macro invocation.
195
+ *
196
+ * A macro with no wrapper sends its prompt unchanged — the common case, and the default, so
197
+ * adding a macro needs no edit here. A macro WITH a wrapper falls back to the bare prompt when
198
+ * the host cannot supply what the wrapper names: better a plain prompt than one asserting a
199
+ * project, an item or a path that is not there.
200
+ *
201
+ * @param macroName the macro being invoked, e.g. `design`
202
+ * @param prompt the macro's resolved prompt text
203
+ * @param ctx what the host knows
204
+ */
205
+ export function buildMacroInvocation(macroName, prompt, ctx = {}) {
206
+ const p = ctx.project;
207
+ if (!p)
208
+ return { message: prompt, displayMessage: `/${macroName}` };
209
+ switch (macroName) {
210
+ case 'design':
211
+ return {
212
+ message: `${designContext(p)}\n${prompt}\n\n${DESIGN_CLOSER}`,
213
+ displayMessage: 'Start the design process for my project.',
214
+ };
215
+ case 'sketch':
216
+ return { message: sketchMessage(p, prompt), displayMessage: 'Quick project outline.' };
217
+ case 'refine':
218
+ case 'refine-item': {
219
+ // Bound to a local so the narrowing survives into the template literals.
220
+ const itemId = ctx.refineItemId;
221
+ const userIntent = itemId !== undefined
222
+ ? `I want to refine backlog item ${itemId}.`
223
+ : 'I want to refine my project requirements.';
224
+ const agentInstructions = itemId !== undefined
225
+ ? `Please use workitem_query to find item "${itemId}", then guide me through refining it using workitem_update.`
226
+ : "Please start by using workitem_query with limit:10 to get an overview, then ask me what I'd like to focus on using ask_user_simple.";
227
+ return {
228
+ message: refineMessage(p, prompt, userIntent, agentInstructions),
229
+ displayMessage: userIntent,
230
+ };
231
+ }
232
+ case 'build': {
233
+ // Nothing to build without an item, and the whole wrapper is about one.
234
+ if (!ctx.workItem)
235
+ return { message: prompt, displayMessage: `/${macroName}` };
236
+ return {
237
+ message: buildMessage(p, prompt, ctx.workItem),
238
+ displayMessage: `Build ${ctx.workItem.itemId}: ${ctx.workItem.title}`,
239
+ };
240
+ }
241
+ case 'session-notes': {
242
+ const titleInstruction = ctx.noteTitle
243
+ ? `The session title is: "${ctx.noteTitle}"`
244
+ : 'Please ask me for a title using ask_user_simple, or generate one from the session summary.';
245
+ return {
246
+ message: sessionNotesMessage(p, prompt, titleInstruction),
247
+ displayMessage: ctx.noteTitle
248
+ ? `Create session note: "${ctx.noteTitle}"`
249
+ : 'Create a session note for this session.',
250
+ };
251
+ }
252
+ case 'prd': {
253
+ const valid = ['vision', 'scope', 'technical', 'success'];
254
+ const section = ctx.section ?? '';
255
+ const sectionInstruction = valid.includes(section)
256
+ ? `The user wants to update the "${section}" section specifically.`
257
+ : 'Ask the user which section they want to update using ask_user_simple.';
258
+ return {
259
+ message: prdMessage(p, prompt, sectionInstruction),
260
+ displayMessage: section
261
+ ? `Update PRD: ${section} section`
262
+ : 'Update the Product Requirements Document',
263
+ };
264
+ }
265
+ case 'architecture': {
266
+ if (!ctx.architecture)
267
+ return { message: prompt, displayMessage: `/${macroName}` };
268
+ return {
269
+ message: architectureMessage(p, prompt, ctx.architecture),
270
+ displayMessage: `Create ${ctx.architecture.displayType ?? ctx.architecture.docType} documentation.`,
271
+ };
272
+ }
273
+ case 'scaffold':
274
+ case 'factory-scaffold': {
275
+ const closingInstruction = macroName === 'factory-scaffold' || ctx.scaffold?.isFactory
276
+ ? 'Start by checking the Application Model with app_model_get. If no model exists, read the PRD with project_document_get and build the model incrementally using app_model_update. Then generate with factory_scaffold.'
277
+ : 'Start by reading the project documents from the database using project_document_list and project_document_get. Then create a plan with todo_write before generating files.';
278
+ return {
279
+ message: scaffoldMessage(p, prompt, ctx.scaffold?.factoryContext ?? '', closingInstruction),
280
+ displayMessage: 'Create project scaffold.',
281
+ };
282
+ }
283
+ default:
284
+ return { message: prompt, displayMessage: `/${macroName}` };
285
+ }
286
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The list of macros a host presents — built once, here, for both hosts.
3
+ *
4
+ * ⚠️ THIS LIVED IN DESKTOP, AND THE CLI SIMPLY DID WITHOUT. Desktop decided what each entry was
5
+ * called, which category it belonged to and which ones came first; the terminal listed raw names
6
+ * in resolver order. That is not a presentation difference, it is the same question answered in
7
+ * one place and not asked in the other — so the two disagreed about the name of every macro.
8
+ *
9
+ * What legitimately differs per host is capability: a terminal cannot render a canvas. That is a
10
+ * parameter (`capabilities`), so neither host re-decides anything else.
11
+ *
12
+ * Spec: project-docs/00-requirements/compilr-dev-sdk/macro-metadata-consolidation.md
13
+ */
14
+ import { type SkillSources } from './prompt-resolver.js';
15
+ import { type MacroCapabilities } from '../project-types/macro-relevance.js';
16
+ import type { MacroCategory, MacroMeta } from '../project-types/types.js';
17
+ /** One row in a slash menu, command palette or picker. */
18
+ export interface MacroListEntry {
19
+ id: string;
20
+ label: string;
21
+ description: string;
22
+ category: MacroCategory;
23
+ icon: string;
24
+ }
25
+ export interface BuildMacroListOptions {
26
+ /** Project directory, for project-scoped skills and bindings. */
27
+ projectPath?: string;
28
+ /** Project type id. Absent means no relevance ordering is applied. */
29
+ projectType?: string;
30
+ /** Extra prompt sources the host injects (factory, agents-coding). */
31
+ sources?: SkillSources;
32
+ /**
33
+ * Metadata for macros the SDK does not ship and therefore cannot describe.
34
+ *
35
+ * The SDK is the source of truth for ITS macros; a package that injects its own prompts is
36
+ * the source of truth for those. `factorySkills` is the case in point — factory depends on
37
+ * the SDK, not the reverse, so no registry here could ever cover it, and `factory-scaffold`
38
+ * rendered as a raw id. Supplying it through this channel keeps the hole visible and owned
39
+ * rather than hardcoded somewhere.
40
+ *
41
+ * Properly, each such package should export this alongside its prompts; until then the host
42
+ * that injects the source supplies it and asserts its own coverage.
43
+ */
44
+ extraMeta?: Record<string, Omit<MacroMeta, 'id'>>;
45
+ /** What this host can render. */
46
+ capabilities?: MacroCapabilities;
47
+ }
48
+ /**
49
+ * Everything typeable after a slash, labelled, and ordered by relevance to the project type.
50
+ *
51
+ * Disabled entries are filtered out — an entry offered and then refused as "Unknown command" is
52
+ * worse than one never offered.
53
+ */
54
+ export declare function buildMacroList(options?: BuildMacroListOptions): MacroListEntry[];
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The list of macros a host presents — built once, here, for both hosts.
3
+ *
4
+ * ⚠️ THIS LIVED IN DESKTOP, AND THE CLI SIMPLY DID WITHOUT. Desktop decided what each entry was
5
+ * called, which category it belonged to and which ones came first; the terminal listed raw names
6
+ * in resolver order. That is not a presentation difference, it is the same question answered in
7
+ * one place and not asked in the other — so the two disagreed about the name of every macro.
8
+ *
9
+ * What legitimately differs per host is capability: a terminal cannot render a canvas. That is a
10
+ * parameter (`capabilities`), so neither host re-decides anything else.
11
+ *
12
+ * Spec: project-docs/00-requirements/compilr-dev-sdk/macro-metadata-consolidation.md
13
+ */
14
+ import { getAllAvailableSkills } from './prompt-resolver.js';
15
+ import { MACRO_META_REGISTRY } from '../project-types/macro-meta.js';
16
+ import { getRelevantMacros } from '../project-types/macro-relevance.js';
17
+ import { platformMacros } from './platform-macros.js';
18
+ /** Derived from the tag, never a name list — a stale name list is how `canvas-styles` leaked. */
19
+ function isCanvasMacro(name) {
20
+ return platformMacros.some((m) => m.name === name && (m.tags ?? []).includes('canvas'));
21
+ }
22
+ /**
23
+ * Everything typeable after a slash, labelled, and ordered by relevance to the project type.
24
+ *
25
+ * Disabled entries are filtered out — an entry offered and then refused as "Unknown command" is
26
+ * worse than one never offered.
27
+ */
28
+ export function buildMacroList(options = {}) {
29
+ const { projectPath, projectType, sources, capabilities, extraMeta } = options;
30
+ const entries = getAllAvailableSkills(projectPath, sources)
31
+ .filter((entry) => entry.enabled !== false)
32
+ // A host that cannot render a canvas must not be OFFERED one. Only ours are withheld: a
33
+ // user's own SKILL.md that happens to be called `canvas` is theirs and still works, which
34
+ // is the same line the CLI's resolver already draws.
35
+ .filter((entry) => !(capabilities?.canvas === false && entry.source === 'sdk' && isCanvasMacro(entry.name)))
36
+ .map((entry) => {
37
+ // A bound command is named for the binding, not for what it resolves to.
38
+ if (entry.source === 'binding') {
39
+ return {
40
+ id: entry.name,
41
+ label: `/${entry.name}`,
42
+ description: entry.description,
43
+ category: 'development',
44
+ icon: 'link',
45
+ };
46
+ }
47
+ // A user's or project's own SKILL.md. Its scope is part of how it reads, because two of
48
+ // them can share a name and the project's wins.
49
+ if (entry.scope) {
50
+ return {
51
+ id: entry.name,
52
+ label: `/${entry.name}`,
53
+ description: `[${entry.scope}] ${entry.description}`,
54
+ category: 'development',
55
+ icon: 'wand',
56
+ };
57
+ }
58
+ // Something we ship. The fallbacks below are a hole, not a feature — they are what made
59
+ // twenty macros render as `business-vision`, `market-analysis`, … and they are kept
60
+ // unreachable by tests/skills/macro-meta-coverage.test.ts.
61
+ const meta = (entry.name in MACRO_META_REGISTRY ? MACRO_META_REGISTRY[entry.name] : undefined) ??
62
+ extraMeta?.[entry.name];
63
+ return {
64
+ id: entry.name,
65
+ label: meta?.label ?? entry.name,
66
+ description: entry.description,
67
+ category: meta?.category ?? 'development',
68
+ icon: meta?.icon ?? 'Zap',
69
+ };
70
+ });
71
+ const relevant = getRelevantMacros(projectType, capabilities);
72
+ if (relevant.length === 0)
73
+ return entries;
74
+ // Promoted entries come back in RELEVANCE order — a business plan leads with its business
75
+ // macros — rather than in whatever order the resolver happened to return them. Everything
76
+ // else keeps its original order behind them.
77
+ const rank = new Map(relevant.map((id, i) => [id, i]));
78
+ const rankOf = (id) => rank.get(id) ?? Number.MAX_SAFE_INTEGER;
79
+ const promoted = entries
80
+ .filter((e) => rank.has(e.id))
81
+ .sort((a, b) => rankOf(a.id) - rankOf(b.id));
82
+ const rest = entries.filter((e) => !rank.has(e.id));
83
+ return [...promoted, ...rest];
84
+ }
@@ -7,8 +7,8 @@
7
7
  * - Validation (quality checks beyond parseSkillMarkdown)
8
8
  * - Binding resolution (config.json slash command remapping)
9
9
  */
10
- import { RESERVED_SKILL_NAMES } from './types.js';
11
- import { platformSkills } from './platform-skills.js';
10
+ import { RESERVED_MACRO_NAMES } from './types.js';
11
+ import { platformMacros } from './platform-macros.js';
12
12
  /**
13
13
  * Detect user/project skills that shadow SDK reserved names.
14
14
  * Called at startup to warn users about collisions introduced by SDK updates.
@@ -18,7 +18,7 @@ import { platformSkills } from './platform-skills.js';
18
18
  * already has a skill with that name.
19
19
  */
20
20
  export function detectCollisions(userSkills) {
21
- const reserved = new Set(RESERVED_SKILL_NAMES);
21
+ const reserved = new Set(RESERVED_MACRO_NAMES);
22
22
  const collisions = [];
23
23
  for (const skill of userSkills) {
24
24
  if (reserved.has(skill.name)) {
@@ -54,7 +54,7 @@ export function formatCollisionWarnings(collisions) {
54
54
  export function diffForkVsUpstream(forkPrompt, upstreamSkillName) {
55
55
  // Find the upstream SDK skill
56
56
  // Check all platform skills + builtins
57
- const allSdk = [...platformSkills];
57
+ const allSdk = [...platformMacros];
58
58
  const upstream = allSdk.find((s) => s.name === upstreamSkillName);
59
59
  if (!upstream)
60
60
  return null;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Platform Macros — Aggregate
3
+ *
4
+ * The prompts we ship. A macro is a named prompt the USER invokes (`/design`, `/prd`); it
5
+ * expands into a message. That is not what a SKILL is — a skill is a capability the MODEL
6
+ * chooses from a catalogue, installed as `SKILL.md` and loaded on demand. These 42 are macros
7
+ * and have always been; they were named "skills" before the two were told apart.
8
+ *
9
+ * They are still built with `defineSkill()` from @compilr-dev/agents, deliberately: that is the
10
+ * shared primitive for "a named prompt with a description", and installed skills extend the same
11
+ * shape. The primitive is not being renamed — the population is.
12
+ *
13
+ * Per-domain files: software-macros.ts, research-macros.ts, business-macros.ts, content-macros.ts,
14
+ * course-macros.ts, book-macros.ts, canvas-macros.ts (+ canvas-exemplars.ts, canvas-icons.ts).
15
+ */
16
+ import type { Skill } from '@compilr-dev/agents';
17
+ export { designMacro, sketchMacro, prdMacro, refineMacro, refineItemMacro, architectureMacro, sessionNotesMacro, buildMacro, scaffoldMacro, } from './software-macros.js';
18
+ export { outlineMacro, literatureReviewMacro, draftSectionMacro, peerReviewMacro, researchScaffoldMacro, } from './research-macros.js';
19
+ export { businessVisionMacro, marketAnalysisMacro, competitorAnalysisMacro, financialModelMacro, pitchOutlineMacro, businessReviewMacro, } from './business-macros.js';
20
+ export { brandSetupMacro, contentStrategyMacro, contentCalendarMacro, createContentMacro, contentReviewMacro, } from './content-macros.js';
21
+ export { curriculumDesignMacro, lessonPlanMacro, assessmentDesignMacro, courseReviewMacro, } from './course-macros.js';
22
+ export { bookOutlineMacro, characterDesignMacro, plotThreadsMacro, sceneBreakdownMacro, bookReviewMacro, } from './book-macros.js';
23
+ export { canvasMacro, infographicMacro, carouselMacro, boardMacro, canvasStylesMacro, } from './canvas-macros.js';
24
+ export { canvasExemplarInfographicMacro, canvasExemplarAppScreenMacro, } from './canvas-exemplars.js';
25
+ export { canvasIconsMacro } from './canvas-icons.js';
26
+ /** Every macro we ship. Count is asserted in tests/skills/platform-macros.test.ts. */
27
+ export declare const platformMacros: Skill[];
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Platform Macros — Aggregate
3
+ *
4
+ * The prompts we ship. A macro is a named prompt the USER invokes (`/design`, `/prd`); it
5
+ * expands into a message. That is not what a SKILL is — a skill is a capability the MODEL
6
+ * chooses from a catalogue, installed as `SKILL.md` and loaded on demand. These 42 are macros
7
+ * and have always been; they were named "skills" before the two were told apart.
8
+ *
9
+ * They are still built with `defineSkill()` from @compilr-dev/agents, deliberately: that is the
10
+ * shared primitive for "a named prompt with a description", and installed skills extend the same
11
+ * shape. The primitive is not being renamed — the population is.
12
+ *
13
+ * Per-domain files: software-macros.ts, research-macros.ts, business-macros.ts, content-macros.ts,
14
+ * course-macros.ts, book-macros.ts, canvas-macros.ts (+ canvas-exemplars.ts, canvas-icons.ts).
15
+ */
16
+ // Software Development
17
+ export { designMacro, sketchMacro, prdMacro, refineMacro, refineItemMacro, architectureMacro, sessionNotesMacro, buildMacro, scaffoldMacro, } from './software-macros.js';
18
+ // Research Paper
19
+ export { outlineMacro, literatureReviewMacro, draftSectionMacro, peerReviewMacro, researchScaffoldMacro, } from './research-macros.js';
20
+ // Business Plan
21
+ export { businessVisionMacro, marketAnalysisMacro, competitorAnalysisMacro, financialModelMacro, pitchOutlineMacro, businessReviewMacro, } from './business-macros.js';
22
+ // Content & Marketing
23
+ export { brandSetupMacro, contentStrategyMacro, contentCalendarMacro, createContentMacro, contentReviewMacro, } from './content-macros.js';
24
+ // Course / Training
25
+ export { curriculumDesignMacro, lessonPlanMacro, assessmentDesignMacro, courseReviewMacro, } from './course-macros.js';
26
+ // Book
27
+ export { bookOutlineMacro, characterDesignMacro, plotThreadsMacro, sceneBreakdownMacro, bookReviewMacro, } from './book-macros.js';
28
+ // Canvas (visual)
29
+ export { canvasMacro, infographicMacro, carouselMacro, boardMacro, canvasStylesMacro, } from './canvas-macros.js';
30
+ // Canvas exemplars — generated from the design handoff; see canvas-exemplars.ts.
31
+ export { canvasExemplarInfographicMacro, canvasExemplarAppScreenMacro, } from './canvas-exemplars.js';
32
+ export { canvasIconsMacro } from './canvas-icons.js';
33
+ // Import all for the aggregate array
34
+ import { designMacro, sketchMacro, prdMacro, refineMacro, refineItemMacro, architectureMacro, sessionNotesMacro, buildMacro, scaffoldMacro, } from './software-macros.js';
35
+ import { outlineMacro, literatureReviewMacro, draftSectionMacro, peerReviewMacro, researchScaffoldMacro, } from './research-macros.js';
36
+ import { businessVisionMacro, marketAnalysisMacro, competitorAnalysisMacro, financialModelMacro, pitchOutlineMacro, businessReviewMacro, } from './business-macros.js';
37
+ import { brandSetupMacro, contentStrategyMacro, contentCalendarMacro, createContentMacro, contentReviewMacro, } from './content-macros.js';
38
+ import { curriculumDesignMacro, lessonPlanMacro, assessmentDesignMacro, courseReviewMacro, } from './course-macros.js';
39
+ import { bookOutlineMacro, characterDesignMacro, plotThreadsMacro, sceneBreakdownMacro, bookReviewMacro, } from './book-macros.js';
40
+ import { canvasMacro, infographicMacro, carouselMacro, boardMacro, canvasStylesMacro, } from './canvas-macros.js';
41
+ import { canvasExemplarInfographicMacro, canvasExemplarAppScreenMacro, } from './canvas-exemplars.js';
42
+ import { canvasIconsMacro } from './canvas-icons.js';
43
+ /** Every macro we ship. Count is asserted in tests/skills/platform-macros.test.ts. */
44
+ export const platformMacros = [
45
+ // Software (9)
46
+ designMacro,
47
+ sketchMacro,
48
+ prdMacro,
49
+ refineMacro,
50
+ refineItemMacro,
51
+ architectureMacro,
52
+ sessionNotesMacro,
53
+ buildMacro,
54
+ scaffoldMacro,
55
+ // Research (5)
56
+ outlineMacro,
57
+ literatureReviewMacro,
58
+ draftSectionMacro,
59
+ peerReviewMacro,
60
+ researchScaffoldMacro,
61
+ // Business (6)
62
+ businessVisionMacro,
63
+ marketAnalysisMacro,
64
+ competitorAnalysisMacro,
65
+ financialModelMacro,
66
+ pitchOutlineMacro,
67
+ businessReviewMacro,
68
+ // Content (5)
69
+ brandSetupMacro,
70
+ contentStrategyMacro,
71
+ contentCalendarMacro,
72
+ createContentMacro,
73
+ contentReviewMacro,
74
+ // Course (4)
75
+ curriculumDesignMacro,
76
+ lessonPlanMacro,
77
+ assessmentDesignMacro,
78
+ courseReviewMacro,
79
+ // Book (5)
80
+ bookOutlineMacro,
81
+ characterDesignMacro,
82
+ plotThreadsMacro,
83
+ sceneBreakdownMacro,
84
+ bookReviewMacro,
85
+ // Canvas (4)
86
+ canvasMacro,
87
+ infographicMacro,
88
+ carouselMacro,
89
+ boardMacro,
90
+ canvasStylesMacro,
91
+ canvasExemplarInfographicMacro,
92
+ canvasExemplarAppScreenMacro,
93
+ canvasIconsMacro,
94
+ ];