busy-cli 0.2.1 → 0.3.1
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +50 -30
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +12 -8
- package/dist/types/schema.d.ts +1650 -76
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/schema.js +12 -2
- package/package.json +2 -2
- package/src/__tests__/view-config.test.ts +277 -0
- package/src/index.ts +3 -0
- package/src/loader.ts +66 -38
- package/src/parser.ts +12 -8
- package/src/types/schema.ts +17 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { loadRepo } from './loader.js';
|
|
2
2
|
export { buildContext, writeContext, get, parentsOf, childrenOf, getConceptContext } from './builders/context.js';
|
|
3
3
|
export { mergeRepos, extendRepo, loadRepoFromJSON } from './merge.js';
|
|
4
|
-
export type { DocId, Slug, Section, ConceptBase, BusyDocument, LocalDef, Operation, ImportDef, EdgeRole, Edge, File, Repo, ContextPayload, FrontMatter, } from './types/schema.js';
|
|
4
|
+
export type { DocId, Slug, Section, ConceptBase, BusyDocument, Playbook, View, Config, LocalDef, Operation, ImportDef, EdgeRole, Edge, File, Repo, ContextPayload, FrontMatter, } from './types/schema.js';
|
|
5
5
|
export type { BuildOpts, ConceptContext } from './builders/context.js';
|
|
6
6
|
export { DocIdSchema, SlugSchema, SectionIdSchema, ConceptIdSchema, SectionSchema, ConceptBaseSchema, LocalDefSchema, SetupSchema, OperationSchema, ImportDefSchema, BusyDocumentSchema, PlaybookSchema, EdgeRoleSchema, EdgeSchema, FileSchema, RepoSchema, ContextPayloadSchema, FrontMatterSchema, } from './types/schema.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGtE,YAAY,EACV,KAAK,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EACL,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGtE,YAAY,EACV,KAAK,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EACL,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,IAAI,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,IAAI,EAYL,MAAM,mBAAmB,CAAC;AAgB3B;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqU7D"}
|
package/dist/loader.js
CHANGED
|
@@ -155,44 +155,52 @@ export async function loadRepo(globs) {
|
|
|
155
155
|
}
|
|
156
156
|
// Build final document structures with inline arrays
|
|
157
157
|
for (const [docId, parts] of docParts) {
|
|
158
|
-
const
|
|
158
|
+
const typesLower = parts.types.map((t) => t.toLowerCase());
|
|
159
|
+
const isPlaybook = typesLower.includes('playbook');
|
|
160
|
+
const isView = typesLower.includes('view');
|
|
161
|
+
const isConfig = typesLower.includes('config');
|
|
162
|
+
// Base fields shared across all document kinds
|
|
163
|
+
const baseFields = {
|
|
164
|
+
id: parts.docId,
|
|
165
|
+
docId: parts.docId,
|
|
166
|
+
slug: parts.docId.toLowerCase(),
|
|
167
|
+
name: parts.frontmatter.Name,
|
|
168
|
+
content: parts.content,
|
|
169
|
+
types: parts.types,
|
|
170
|
+
extends: parts.extends,
|
|
171
|
+
sectionRef: `${parts.docId}#`, // Root reference
|
|
172
|
+
imports: parts.imports,
|
|
173
|
+
localdefs: parts.localdefs,
|
|
174
|
+
setup: parts.setup,
|
|
175
|
+
operations: parts.operations,
|
|
176
|
+
};
|
|
159
177
|
if (isPlaybook) {
|
|
160
178
|
// Extract sequence from ExecutePlaybook operation
|
|
161
179
|
const sequence = extractPlaybookSequence(parts.sections);
|
|
180
|
+
const doc = { ...baseFields, kind: 'playbook', sequence };
|
|
181
|
+
docs.push(doc);
|
|
182
|
+
}
|
|
183
|
+
else if (isView) {
|
|
184
|
+
// Extract template section with full content (including children)
|
|
185
|
+
const displaySection = findSection(parts.sections, 'display');
|
|
186
|
+
let displayContent;
|
|
187
|
+
if (displaySection) {
|
|
188
|
+
// Reconstruct full template from section + children content
|
|
189
|
+
displayContent = getSectionFullContent(displaySection);
|
|
190
|
+
}
|
|
162
191
|
const doc = {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
slug: parts.docId.toLowerCase(),
|
|
167
|
-
name: parts.frontmatter.Name,
|
|
168
|
-
content: parts.content,
|
|
169
|
-
types: parts.types,
|
|
170
|
-
extends: parts.extends,
|
|
171
|
-
sectionRef: `${parts.docId}#`, // Root reference
|
|
172
|
-
imports: parts.imports,
|
|
173
|
-
localdefs: parts.localdefs,
|
|
174
|
-
setup: parts.setup,
|
|
175
|
-
operations: parts.operations,
|
|
176
|
-
sequence,
|
|
192
|
+
...baseFields,
|
|
193
|
+
kind: 'view',
|
|
194
|
+
display: displayContent,
|
|
177
195
|
};
|
|
178
196
|
docs.push(doc);
|
|
179
197
|
}
|
|
198
|
+
else if (isConfig) {
|
|
199
|
+
const doc = { ...baseFields, kind: 'config' };
|
|
200
|
+
docs.push(doc);
|
|
201
|
+
}
|
|
180
202
|
else {
|
|
181
|
-
const doc = {
|
|
182
|
-
kind: 'document',
|
|
183
|
-
id: parts.docId,
|
|
184
|
-
docId: parts.docId,
|
|
185
|
-
slug: parts.docId.toLowerCase(),
|
|
186
|
-
name: parts.frontmatter.Name,
|
|
187
|
-
content: parts.content,
|
|
188
|
-
types: parts.types,
|
|
189
|
-
extends: parts.extends,
|
|
190
|
-
sectionRef: `${parts.docId}#`, // Root reference
|
|
191
|
-
imports: parts.imports,
|
|
192
|
-
localdefs: parts.localdefs,
|
|
193
|
-
setup: parts.setup,
|
|
194
|
-
operations: parts.operations,
|
|
195
|
-
};
|
|
203
|
+
const doc = { ...baseFields, kind: 'document' };
|
|
196
204
|
docs.push(doc);
|
|
197
205
|
}
|
|
198
206
|
}
|
|
@@ -332,6 +340,18 @@ function resolveSymbol(nameOrLabel, currentDocId, localdefs, docs, symbols) {
|
|
|
332
340
|
}
|
|
333
341
|
return undefined;
|
|
334
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Get the full content of a section including all nested children.
|
|
345
|
+
* Reconstructs the original markdown by walking the section tree.
|
|
346
|
+
*/
|
|
347
|
+
function getSectionFullContent(section) {
|
|
348
|
+
let content = section.content;
|
|
349
|
+
for (const child of section.children) {
|
|
350
|
+
const prefix = '#'.repeat(child.depth);
|
|
351
|
+
content += `\n${prefix} ${child.title}\n${getSectionFullContent(child)}`;
|
|
352
|
+
}
|
|
353
|
+
return content.trim();
|
|
354
|
+
}
|
|
335
355
|
/**
|
|
336
356
|
* Extract sequence of operations from a playbook's ExecutePlaybook operation
|
|
337
357
|
* Looks for sections with "Step" in the title and extracts Target metadata
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EACL,eAAe,IAAI,YAAY,EAAG,8CAA8C;AAChF,YAAY,EAGb,MAAM,mBAAmB,CAAC;AA6G3B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,CAiE1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,YAAY,GAAG,YAAY,EACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EACL,eAAe,IAAI,YAAY,EAAG,8CAA8C;AAChF,YAAY,EAGb,MAAM,mBAAmB,CAAC;AA6G3B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,CAiE1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,YAAY,GAAG,YAAY,EACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAAC,CA2D7C"}
|
package/dist/parser.js
CHANGED
|
@@ -170,13 +170,15 @@ export function resolveImports(document, basePath, visited = new Set()) {
|
|
|
170
170
|
for (const imp of document.imports) {
|
|
171
171
|
// Resolve the import path
|
|
172
172
|
const importPath = resolve(dirname(basePath), imp.path);
|
|
173
|
-
// Check for circular imports
|
|
173
|
+
// Check for circular imports — warn and skip instead of crashing
|
|
174
174
|
if (visited.has(importPath)) {
|
|
175
|
-
|
|
175
|
+
console.warn(`⚠ Circular import skipped: ${imp.path} (from ${basePath})`);
|
|
176
|
+
continue;
|
|
176
177
|
}
|
|
177
|
-
// Check if file exists
|
|
178
|
+
// Check if file exists — warn and skip instead of crashing
|
|
178
179
|
if (!existsSync(importPath)) {
|
|
179
|
-
|
|
180
|
+
console.warn(`⚠ Import not found: ${imp.path} (resolved to ${importPath})`);
|
|
181
|
+
continue;
|
|
180
182
|
}
|
|
181
183
|
// Mark as visited
|
|
182
184
|
visited.add(importPath);
|
|
@@ -192,7 +194,7 @@ export function resolveImports(document, basePath, visited = new Set()) {
|
|
|
192
194
|
const hasDefinition = importedDoc.definitions.some((def) => def.name.toLowerCase() === imp.anchor.toLowerCase() ||
|
|
193
195
|
slugify(def.name) === imp.anchor.toLowerCase());
|
|
194
196
|
if (!hasOperation && !hasDefinition) {
|
|
195
|
-
|
|
197
|
+
console.warn(`⚠ Anchor '${imp.anchor}' not found in ${imp.path}`);
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
// Store resolved document
|
|
@@ -201,10 +203,12 @@ export function resolveImports(document, basePath, visited = new Set()) {
|
|
|
201
203
|
const nestedResolved = resolveImports(importedDoc, importPath, visited);
|
|
202
204
|
Object.assign(resolved, nestedResolved);
|
|
203
205
|
}
|
|
204
|
-
|
|
205
|
-
//
|
|
206
|
-
|
|
206
|
+
catch (e) {
|
|
207
|
+
// Don't crash on nested resolution failures
|
|
208
|
+
console.warn(`⚠ Failed to resolve nested imports in ${imp.path}: ${e}`);
|
|
207
209
|
}
|
|
210
|
+
// NOTE: we intentionally keep importPath in `visited` — once resolved,
|
|
211
|
+
// don't re-resolve in other branches (prevents exponential recursion)
|
|
208
212
|
}
|
|
209
213
|
return resolved;
|
|
210
214
|
}
|