Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/spec/scripts/build-skill-references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,24 @@ const SKILL_MAP: Record<string, string[]> = {
function extractLocalImports(filePath: string): string[] {
const content = fs.readFileSync(filePath, 'utf-8');
const imports: string[] = [];
const re = /^import\s+.*\s+from\s+['"](\.[^'"]+)['"]/gm;
const dir = path.dirname(filePath);
// Match `import … from '<relative>'`, tolerating a multi-line import clause.
// The clause between `import` and `from` never contains a `;`, quote, or `(`,
// so excluding those keeps the non-greedy span from bridging across a
// statement boundary, a side-effect import (`import './x'`), or a dynamic
// `import(...)` into the wrong specifier. A plain `.` (the old pattern) does
// not cross newlines, so multi-line named imports were silently dropped.
const re = /^import\b[^;'"()]*?\bfrom\s*['"](\.[^'"]+)['"]/gm;
let match: RegExpExecArray | null;
while ((match = re.exec(content)) !== null) {
const importSpec = match[1];
const dir = path.dirname(filePath);
let resolved = path.resolve(dir, importSpec);
if (!resolved.endsWith('.ts')) resolved += '.ts';
// ESM specifiers may carry a `.js` extension that maps to a `.ts` source
// (`./types.js` → `./types.ts`); otherwise append `.ts` for an
// extensionless local specifier. Blindly appending `.ts` turned `.js`
// imports into a non-existent `foo.js.ts` that was then dropped.
if (resolved.endsWith('.js')) resolved = resolved.slice(0, -3) + '.ts';
else if (!resolved.endsWith('.ts')) resolved += '.ts';
if (fs.existsSync(resolved)) {
imports.push(path.relative(SPEC_SRC, resolved));
}
Expand Down
1 change: 1 addition & 0 deletions skills/objectstack-platform/references/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ from `node_modules` — there is no local copy in the skill bundle.
- `node_modules/@objectstack/spec/src/shared/identifiers.zod.ts` — System Identifier Schema
- `node_modules/@objectstack/spec/src/shared/lazy-schema.ts` — Wrap a Zod schema constructor so its body is only evaluated on first use.
- `node_modules/@objectstack/spec/src/shared/protection.zod.ts` — Package-level metadata protection (ADR-0010 §3.7 — Phase 4.3)
- `node_modules/@objectstack/spec/src/system/tenant.zod.ts` — Tenant Schema (Multi-Tenant Architecture)
- `node_modules/@objectstack/spec/src/ui/action.zod.ts` — Action Parameter Schema
- `node_modules/@objectstack/spec/src/ui/app.zod.ts` — Base Navigation Item Schema
- `node_modules/@objectstack/spec/src/ui/i18n.zod.ts` — I18n Object Schema
Expand Down