lua-cli 3.12.1 → 3.13.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.
- package/dist/api/logs.api.service.d.ts +6 -3
- package/dist/api/logs.api.service.d.ts.map +1 -1
- package/dist/api/logs.api.service.js +5 -4
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/cli/command-definitions.d.ts.map +1 -1
- package/dist/cli/command-definitions.js +24 -2
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +2 -11
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat-log-probe.d.ts +59 -0
- package/dist/commands/chat-log-probe.d.ts.map +1 -0
- package/dist/commands/chat-log-probe.js +91 -0
- package/dist/commands/chat-log-probe.js.map +1 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +134 -28
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/compile.d.ts +7 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +32 -2
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +7 -8
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +108 -23
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/devices.d.ts.map +1 -1
- package/dist/commands/devices.js +3 -2
- package/dist/commands/devices.js.map +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +43 -20
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/features.d.ts.map +1 -1
- package/dist/commands/features.js +2 -12
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/governance.d.ts.map +1 -1
- package/dist/commands/governance.js +4 -8
- package/dist/commands/governance.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +12 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/integrations.d.ts.map +1 -1
- package/dist/commands/integrations.js +4 -2
- package/dist/commands/integrations.js.map +1 -1
- package/dist/commands/jobs.d.ts.map +1 -1
- package/dist/commands/jobs.js +61 -23
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/log-tip.d.ts +79 -0
- package/dist/commands/log-tip.d.ts.map +1 -0
- package/dist/commands/log-tip.js +91 -0
- package/dist/commands/log-tip.js.map +1 -0
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +97 -136
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.d.ts.map +1 -1
- package/dist/commands/marketplace.js +14 -25
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +17 -19
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +2 -1
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +4 -30
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/postprocessors.d.ts.map +1 -1
- package/dist/commands/postprocessors.js +43 -17
- package/dist/commands/postprocessors.js.map +1 -1
- package/dist/commands/preprocessors.d.ts.map +1 -1
- package/dist/commands/preprocessors.js +43 -17
- package/dist/commands/preprocessors.js.map +1 -1
- package/dist/commands/production.d.ts.map +1 -1
- package/dist/commands/production.js +2 -12
- package/dist/commands/production.js.map +1 -1
- package/dist/commands/push-helpers.d.ts +42 -0
- package/dist/commands/push-helpers.d.ts.map +1 -0
- package/dist/commands/push-helpers.js +48 -0
- package/dist/commands/push-helpers.js.map +1 -0
- package/dist/commands/push.d.ts +2 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +269 -54
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/pushBackup.d.ts.map +1 -1
- package/dist/commands/pushBackup.js +7 -1
- package/dist/commands/pushBackup.js.map +1 -1
- package/dist/commands/resources.d.ts.map +1 -1
- package/dist/commands/resources.js +2 -12
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/commands/skills.js +51 -36
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/status.d.ts +14 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +734 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +37 -2
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +4 -0
- package/dist/commands/telemetry.js.map +1 -1
- package/dist/commands/test-output.helpers.d.ts +24 -0
- package/dist/commands/test-output.helpers.d.ts.map +1 -0
- package/dist/commands/test-output.helpers.js +62 -0
- package/dist/commands/test-output.helpers.js.map +1 -0
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +236 -76
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/webhooks.d.ts.map +1 -1
- package/dist/commands/webhooks.js +34 -21
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts +50 -14
- package/dist/compiler/agent-traverser.d.ts.map +1 -1
- package/dist/compiler/agent-traverser.js +191 -86
- package/dist/compiler/agent-traverser.js.map +1 -1
- package/dist/compiler/compiler.d.ts +32 -0
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compiler.js +143 -18
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/plugins/base.d.ts +21 -0
- package/dist/compiler/plugins/base.d.ts.map +1 -1
- package/dist/compiler/plugins/base.js +10 -0
- package/dist/compiler/plugins/base.js.map +1 -1
- package/dist/compiler/plugins/skill.plugin.d.ts +35 -9
- package/dist/compiler/plugins/skill.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/skill.plugin.js +131 -84
- package/dist/compiler/plugins/skill.plugin.js.map +1 -1
- package/dist/compiler/types.d.ts +33 -0
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/compiler/types.js.map +1 -1
- package/dist/compiler/utils/ast-helpers.d.ts +1 -16
- package/dist/compiler/utils/ast-helpers.d.ts.map +1 -1
- package/dist/compiler/utils/ast-helpers.js +2 -31
- package/dist/compiler/utils/ast-helpers.js.map +1 -1
- package/dist/compiler/utils/common.d.ts +14 -0
- package/dist/compiler/utils/common.d.ts.map +1 -1
- package/dist/compiler/utils/common.js +38 -0
- package/dist/compiler/utils/common.js.map +1 -1
- package/dist/compiler/utils/path-resolver.d.ts +67 -10
- package/dist/compiler/utils/path-resolver.d.ts.map +1 -1
- package/dist/compiler/utils/path-resolver.js +120 -24
- package/dist/compiler/utils/path-resolver.js.map +1 -1
- package/dist/compiler/utils/reference-resolver.d.ts +196 -0
- package/dist/compiler/utils/reference-resolver.d.ts.map +1 -0
- package/dist/compiler/utils/reference-resolver.js +1030 -0
- package/dist/compiler/utils/reference-resolver.js.map +1 -0
- package/dist/compiler/utils/schema-converter.d.ts +25 -0
- package/dist/compiler/utils/schema-converter.d.ts.map +1 -1
- package/dist/compiler/utils/schema-converter.js +83 -4
- package/dist/compiler/utils/schema-converter.js.map +1 -1
- package/dist/compiler/utils/workspace.d.ts +35 -0
- package/dist/compiler/utils/workspace.d.ts.map +1 -0
- package/dist/compiler/utils/workspace.js +121 -0
- package/dist/compiler/utils/workspace.js.map +1 -0
- package/dist/compiler/utils/zod-runtime.mjs +5334 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/backup.d.ts +19 -1
- package/dist/interfaces/backup.d.ts.map +1 -1
- package/dist/interfaces/chat.d.ts +2 -2
- package/dist/interfaces/chat.d.ts.map +1 -1
- package/dist/interfaces/logs.d.ts +7 -4
- package/dist/interfaces/logs.d.ts.map +1 -1
- package/dist/primitives/base.handler.d.ts +10 -0
- package/dist/primitives/base.handler.d.ts.map +1 -1
- package/dist/primitives/base.handler.js +73 -44
- package/dist/primitives/base.handler.js.map +1 -1
- package/dist/primitives/job.handler.d.ts +5 -0
- package/dist/primitives/job.handler.d.ts.map +1 -1
- package/dist/primitives/job.handler.js +9 -0
- package/dist/primitives/job.handler.js.map +1 -1
- package/dist/primitives/webhook.handler.d.ts +2 -1
- package/dist/primitives/webhook.handler.d.ts.map +1 -1
- package/dist/primitives/webhook.handler.js +7 -1
- package/dist/primitives/webhook.handler.js.map +1 -1
- package/dist/services/auth.d.ts +8 -0
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +19 -0
- package/dist/services/auth.js.map +1 -1
- package/dist/services/sandbox.service.d.ts.map +1 -1
- package/dist/services/sandbox.service.js +6 -2
- package/dist/services/sandbox.service.js.map +1 -1
- package/dist/utils/aliases.d.ts +7 -0
- package/dist/utils/aliases.d.ts.map +1 -0
- package/dist/utils/aliases.js +457 -0
- package/dist/utils/aliases.js.map +1 -0
- package/dist/utils/backup-helpers.d.ts +24 -0
- package/dist/utils/backup-helpers.d.ts.map +1 -1
- package/dist/utils/backup-helpers.js +94 -8
- package/dist/utils/backup-helpers.js.map +1 -1
- package/dist/utils/chat-attachments.d.ts +15 -0
- package/dist/utils/chat-attachments.d.ts.map +1 -0
- package/dist/utils/chat-attachments.js +116 -0
- package/dist/utils/chat-attachments.js.map +1 -0
- package/dist/utils/cli.d.ts +24 -6
- package/dist/utils/cli.d.ts.map +1 -1
- package/dist/utils/cli.js +23 -9
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/hints.d.ts +81 -0
- package/dist/utils/hints.d.ts.map +1 -0
- package/dist/utils/hints.js +83 -0
- package/dist/utils/hints.js.map +1 -0
- package/dist/utils/suggest.d.ts +3 -0
- package/dist/utils/suggest.d.ts.map +1 -0
- package/dist/utils/suggest.js +34 -0
- package/dist/utils/suggest.js.map +1 -0
- package/dist/utils/write-info.d.ts +9 -0
- package/dist/utils/write-info.d.ts.map +1 -0
- package/dist/utils/write-info.js +11 -0
- package/dist/utils/write-info.js.map +1 -0
- package/docs/README.md +1 -1
- package/node_modules/@lua/shared-types/dist/index.d.mts +64 -2
- package/node_modules/@lua/shared-types/dist/index.d.ts +64 -2
- package/node_modules/@lua/shared-types/dist/index.js +27 -0
- package/node_modules/@lua/shared-types/dist/index.mjs +24 -0
- package/node_modules/@lua/shared-types/src/channel.type.ts +1 -0
- package/node_modules/@lua/shared-types/src/client-tools.types.ts +47 -0
- package/node_modules/@lua/shared-types/src/index.ts +2 -0
- package/node_modules/@lua/shared-types/src/vm-execution-log.types.ts +41 -0
- package/package.json +10 -6
- package/scripts/build-vendor.mjs +53 -0
- package/scripts/vendor-entry.mjs +11 -0
- package/template/examples/skills/tools/CustomDataTool.ts +1 -5
- package/template/examples/skills/tools/PremiumFeatureTool.ts +18 -18
- package/template/package.json +1 -1
|
@@ -28,8 +28,8 @@ import fs from 'fs';
|
|
|
28
28
|
import { pluginRegistry } from './plugins/registry.js';
|
|
29
29
|
import { agentPlugin } from './plugins/agent.plugin.js';
|
|
30
30
|
import { shouldSkipFile } from './utils/common.js';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
31
|
+
import { resolveModuleSpecifier, registerProjectRootDir } from './utils/path-resolver.js';
|
|
32
|
+
import { resolveArrayRefs, reportDeopt, formatSarifWarning, } from './utils/reference-resolver.js';
|
|
33
33
|
/**
|
|
34
34
|
* All primitive types and their configuration.
|
|
35
35
|
* To add a new primitive type, just add an entry here.
|
|
@@ -73,6 +73,27 @@ export class AgentTraverser {
|
|
|
73
73
|
tsConfigFilePath: path.join(rootDir, 'tsconfig.json'),
|
|
74
74
|
skipAddingFilesFromTsConfig: true,
|
|
75
75
|
});
|
|
76
|
+
// Register this Project → rootDir so plugin code that only has a
|
|
77
|
+
// SourceFile in hand (SkillPlugin's `resolveArrayRefs({ project })`
|
|
78
|
+
// call sites) can recover the correct rootDir via
|
|
79
|
+
// `getProjectRootDir(project)` instead of falling through to
|
|
80
|
+
// `process.cwd()`. Without this, tsconfig `paths` aliases in a
|
|
81
|
+
// skill's `tools: [...]` / `.addTools([...])` arrays resolve
|
|
82
|
+
// against whatever directory the CLI was invoked from — which
|
|
83
|
+
// regresses the per-rootDir guarantee the resolver promises.
|
|
84
|
+
registerProjectRootDir(this.project, this.rootDir);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Absolute paths of every SourceFile the traverser loaded during `traverse()`,
|
|
88
|
+
* including cross-root files pulled in by the reference resolver
|
|
89
|
+
* (e.g. `packages/shared/utils.ts` in a monorepo agent).
|
|
90
|
+
*
|
|
91
|
+
* The compiler reads this to include cross-root sources in
|
|
92
|
+
* `manifest.projectFiles`, so `lua push backup` backs up everything the
|
|
93
|
+
* compiler actually needed — not just files under `rootDir`. See BAC-69.
|
|
94
|
+
*/
|
|
95
|
+
getAllLoadedSourceFilePaths() {
|
|
96
|
+
return this.project.getSourceFiles().map((sf) => sf.getFilePath());
|
|
76
97
|
}
|
|
77
98
|
/**
|
|
78
99
|
* Log a debug message if debug mode is enabled.
|
|
@@ -98,21 +119,45 @@ export class AgentTraverser {
|
|
|
98
119
|
return null;
|
|
99
120
|
}
|
|
100
121
|
this.log(`🤖 Found agent: ${agentConfig.name} in ${agentConfig.sourcePath}`);
|
|
101
|
-
// Step 2:
|
|
102
|
-
const agentFile = this.project.addSourceFileAtPath(agentConfig.sourcePath);
|
|
103
|
-
// Step 3: Collect all primitives (agent + its registered children)
|
|
122
|
+
// Step 2: Collect all primitives (agent + its registered children)
|
|
104
123
|
const primitives = [];
|
|
105
124
|
// The agent itself is a primitive
|
|
106
125
|
const { refs: _refs, ...agentMetadata } = agentConfig;
|
|
107
126
|
primitives.push(agentMetadata);
|
|
108
|
-
// Discover child primitives from the agent's config arrays
|
|
127
|
+
// Discover child primitives from the agent's config arrays.
|
|
128
|
+
// The resolver already carries each ref's source file, so we don't need
|
|
129
|
+
// another `findImportSource` pass — we just ask the right plugin to
|
|
130
|
+
// detect the primitive in that file.
|
|
109
131
|
for (const config of PRIMITIVE_TYPES) {
|
|
110
132
|
const refs = agentConfig.refs.get(config.kind) || [];
|
|
111
133
|
for (const ref of refs) {
|
|
112
|
-
|
|
113
|
-
|
|
134
|
+
// Inline-new refs at the agent-registration level (e.g.
|
|
135
|
+
// `mcpServers: [new LuaMCPServer({...})]`) can't be bundled: the
|
|
136
|
+
// class name is generic, so there's no source-level identifier
|
|
137
|
+
// the bundler can import. Tell the user to name the instance
|
|
138
|
+
// with a `const x = new ...`, and skip this ref — rather than
|
|
139
|
+
// hitting the fallback `detected.length === 1` path which would
|
|
140
|
+
// mis-attribute it to whichever primitive happens to be declared
|
|
141
|
+
// first in the agent file.
|
|
142
|
+
if (ref.newExpression && !ref.declaration) {
|
|
143
|
+
const className = ref.identifierName;
|
|
144
|
+
const { line, column } = ref.sourceFile.getLineAndColumnAtPos(ref.newExpression.getStart());
|
|
145
|
+
console.warn(formatSarifWarning({
|
|
146
|
+
ruleId: 'lua/unresolved-primitive-ref',
|
|
147
|
+
filePath: ref.sourceFile.getFilePath(),
|
|
148
|
+
line,
|
|
149
|
+
column,
|
|
150
|
+
message: `inline "new ${className}({...})" in agent.${config.configProperty} cannot be ` +
|
|
151
|
+
`bundled: the primitive has no source-level name the compiler can import`,
|
|
152
|
+
hint: `assign it first: \`const myPrimitive = new ${className}({...}); ` +
|
|
153
|
+
`${config.configProperty}: [myPrimitive]\``,
|
|
154
|
+
}));
|
|
114
155
|
continue;
|
|
115
|
-
|
|
156
|
+
}
|
|
157
|
+
const sourcePath = ref.sourceFile.getFilePath();
|
|
158
|
+
const primitive = this.extractPrimitive(config.kind, sourcePath, ref.identifierName, {
|
|
159
|
+
viaDefaultImport: ref.viaDefaultImport === true,
|
|
160
|
+
});
|
|
116
161
|
if (!primitive)
|
|
117
162
|
continue;
|
|
118
163
|
primitives.push(primitive);
|
|
@@ -182,7 +227,15 @@ export class AgentTraverser {
|
|
|
182
227
|
const detection = agentPlugin.detectWithConfig(sourceFile);
|
|
183
228
|
if (!detection)
|
|
184
229
|
return null;
|
|
185
|
-
// Primitive ref discovery stays here (unique to traverser)
|
|
230
|
+
// Primitive ref discovery stays here (unique to traverser).
|
|
231
|
+
// Each kind gets its own walk with a fresh `visited` set — sharing
|
|
232
|
+
// one across kinds is incorrect: `followIdentifier` marks visit keys
|
|
233
|
+
// before resolving (for cycle detection), so a shared set makes the
|
|
234
|
+
// second kind see `webhooks` as "already visited" when it only shared
|
|
235
|
+
// an identifier with `jobs`, and silently drop the ref. That's the
|
|
236
|
+
// exact LUA-221-class silent-drop bug we're trying to eliminate.
|
|
237
|
+
// ts-morph caches `addSourceFileAtPath` on the Project anyway, so
|
|
238
|
+
// there's no cross-file-load cost from repeated walks.
|
|
186
239
|
const refs = new Map();
|
|
187
240
|
for (const primitiveType of PRIMITIVE_TYPES) {
|
|
188
241
|
refs.set(primitiveType.kind, this.extractArrayRefs(detection.configNode, primitiveType.configProperty));
|
|
@@ -195,91 +248,82 @@ export class AgentTraverser {
|
|
|
195
248
|
return result;
|
|
196
249
|
}
|
|
197
250
|
/**
|
|
198
|
-
* Extract array references from an object literal property
|
|
199
|
-
* Handles
|
|
251
|
+
* Extract array references from an object literal property using the
|
|
252
|
+
* shared reference resolver. Handles inline arrays, variable refs (same
|
|
253
|
+
* file and cross-file), spreads, property access, re-export barrels,
|
|
254
|
+
* and path aliases uniformly — see `reference-resolver.ts` for the
|
|
255
|
+
* supported expression shapes.
|
|
256
|
+
*
|
|
257
|
+
* On deopt (the resolver hit a dynamic expression it can't statically
|
|
258
|
+
* evaluate), emits a SARIF-style warning pointing at the offending node
|
|
259
|
+
* and keeps whatever partial value the resolver managed to produce.
|
|
260
|
+
* This is much more useful than the previous behavior — silently
|
|
261
|
+
* returning an empty list — which was the root of LUA-221.
|
|
200
262
|
*/
|
|
201
263
|
extractArrayRefs(config, propName) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return refs;
|
|
225
|
-
}
|
|
226
|
-
// ===========================================================================
|
|
227
|
-
// REFERENCE RESOLUTION
|
|
228
|
-
// ===========================================================================
|
|
229
|
-
/**
|
|
230
|
-
* Resolve a primitive reference to its source file path.
|
|
231
|
-
*/
|
|
232
|
-
resolveReference(ref, sourceFile) {
|
|
233
|
-
// Check imports first, fall back to same file for local definitions
|
|
234
|
-
// (e.g., const myJob = defineJob({ ... }); used in same file)
|
|
235
|
-
return findImportSource(ref.name, sourceFile, this.resolveImportPath.bind(this));
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Resolve a module specifier to an absolute file path.
|
|
239
|
-
*/
|
|
240
|
-
resolveImportPath(specifier, fromFile) {
|
|
241
|
-
// Handle .js extension in modern TS (NodeNext module resolution)
|
|
242
|
-
let normalized = specifier;
|
|
243
|
-
if (specifier.endsWith('.js')) {
|
|
244
|
-
normalized = specifier.slice(0, -3);
|
|
245
|
-
}
|
|
246
|
-
const extensions = ['.ts', '.tsx', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js'];
|
|
247
|
-
// Try path alias resolution first (e.g., @/tools/MyTool)
|
|
248
|
-
const aliasResolved = resolvePathAlias(normalized);
|
|
249
|
-
if (aliasResolved) {
|
|
250
|
-
for (const ext of extensions) {
|
|
251
|
-
const fullPath = ext.startsWith('/') ? path.join(aliasResolved, ext) : aliasResolved + ext;
|
|
252
|
-
if (fs.existsSync(fullPath)) {
|
|
253
|
-
return fullPath;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return aliasResolved + '.ts'; // fallback
|
|
257
|
-
}
|
|
258
|
-
// Handle relative imports
|
|
259
|
-
if (normalized.startsWith('./') || normalized.startsWith('../')) {
|
|
260
|
-
const dir = path.dirname(fromFile);
|
|
261
|
-
const basePath = path.resolve(dir, normalized);
|
|
262
|
-
for (const ext of extensions) {
|
|
263
|
-
const fullPath = ext.startsWith('/') ? path.join(basePath, ext) : basePath + ext;
|
|
264
|
-
if (fs.existsSync(fullPath)) {
|
|
265
|
-
return fullPath;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
264
|
+
const prop = config.getProperty(propName);
|
|
265
|
+
if (!prop || !Node.isPropertyAssignment(prop))
|
|
266
|
+
return [];
|
|
267
|
+
const value = prop.getInitializer();
|
|
268
|
+
if (!value)
|
|
269
|
+
return [];
|
|
270
|
+
// Fresh `visited` per call — shared-across-kinds was a silent-drop bug
|
|
271
|
+
// (see comment in detectAgentInFile). `rootDir` flows through so the
|
|
272
|
+
// resolver's tsconfig-paths alias lookup uses this project's config,
|
|
273
|
+
// not process.cwd()'s (which leaks across multi-project Node runs).
|
|
274
|
+
const ctx = {
|
|
275
|
+
project: this.project,
|
|
276
|
+
rootDir: this.rootDir,
|
|
277
|
+
log: this.log.bind(this),
|
|
278
|
+
};
|
|
279
|
+
const result = resolveArrayRefs(value, ctx);
|
|
280
|
+
if (!result.confident) {
|
|
281
|
+
// Visible by default — swallowing a deopt here reproduces LUA-221.
|
|
282
|
+
console.warn(reportDeopt(result, propName));
|
|
268
283
|
}
|
|
269
|
-
return
|
|
284
|
+
return result.value;
|
|
270
285
|
}
|
|
271
286
|
/**
|
|
272
287
|
* Resolve dependencies for a primitive by delegating to its plugin.
|
|
288
|
+
*
|
|
289
|
+
* Belt-and-suspenders try/catch around `addSourceFileAtPath`: by
|
|
290
|
+
* construction the resolver has already loaded this path into the
|
|
291
|
+
* project, so it should always be present. But if something upstream
|
|
292
|
+
* races (a test deletes a fixture, an LSP concurrent-compile deletes
|
|
293
|
+
* a file under us, a permissions error on re-read), throwing here
|
|
294
|
+
* would abort the whole compile with a stack trace. Emit a SARIF
|
|
295
|
+
* warning and return empty instead — the primitive itself will still
|
|
296
|
+
* appear in the manifest, it just won't have its nested tools/refs
|
|
297
|
+
* resolved, which the user can then investigate.
|
|
273
298
|
*/
|
|
274
299
|
resolveReferencesForPrimitive(metadata, sourcePath) {
|
|
275
300
|
const plugin = pluginRegistry.get(metadata.kind);
|
|
276
301
|
if (!plugin?.resolveReferences) {
|
|
277
302
|
return [];
|
|
278
303
|
}
|
|
279
|
-
|
|
304
|
+
let sourceFile;
|
|
305
|
+
try {
|
|
306
|
+
sourceFile = this.project.addSourceFileAtPath(sourcePath);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
console.warn(formatSarifWarning({
|
|
310
|
+
ruleId: 'lua/missing-primitive-declaration',
|
|
311
|
+
filePath: sourcePath,
|
|
312
|
+
message: `unable to load source for ${metadata.kind} "${metadata.name}": ` +
|
|
313
|
+
(error instanceof Error ? error.message : String(error)),
|
|
314
|
+
hint: `verify the file exists and is readable; nested references ` +
|
|
315
|
+
`for this primitive will not be resolved`,
|
|
316
|
+
}));
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
// Plugins still have a `resolveImportPath` hook in their context
|
|
320
|
+
// (skill → tool resolution). Wire it to the shared resolver — both
|
|
321
|
+
// the agent-level walk and the per-primitive resolution flow now
|
|
322
|
+
// go through the same helper, so drift between them is impossible.
|
|
323
|
+
const rootDir = this.rootDir;
|
|
280
324
|
const context = {
|
|
281
325
|
project: this.project,
|
|
282
|
-
resolveImportPath:
|
|
326
|
+
resolveImportPath: (specifier, fromFile) => resolveModuleSpecifier(specifier, fromFile, rootDir) ?? null,
|
|
283
327
|
getPlugin: (kind) => pluginRegistry.get(kind),
|
|
284
328
|
log: this.log.bind(this),
|
|
285
329
|
};
|
|
@@ -290,8 +334,20 @@ export class AgentTraverser {
|
|
|
290
334
|
// ===========================================================================
|
|
291
335
|
/**
|
|
292
336
|
* Extract a primitive's metadata using its plugin's detect() method.
|
|
337
|
+
*
|
|
338
|
+
* Matching order:
|
|
339
|
+
* 1. If the ref reached the target via `import x from './t'`, prefer the
|
|
340
|
+
* default export on the target side — the consumer-side binding name
|
|
341
|
+
* (`x`) is arbitrary and won't line up with the target's exportName.
|
|
342
|
+
* Without this, a file with both a default-exported primitive and a
|
|
343
|
+
* named one would emit a spurious "missing primitive" warning just
|
|
344
|
+
* because `detected.length !== 1`.
|
|
345
|
+
* 2. Otherwise match by `exportName` or `name` equal to `refName`.
|
|
346
|
+
* 3. Singleton fallback: if the file declares exactly one primitive of
|
|
347
|
+
* this kind, assume it's the one the user meant (covers inline
|
|
348
|
+
* `export default defineJob({...})` single-primitive files).
|
|
293
349
|
*/
|
|
294
|
-
extractPrimitive(kind, sourcePath, refName) {
|
|
350
|
+
extractPrimitive(kind, sourcePath, refName, opts = {}) {
|
|
295
351
|
const plugin = pluginRegistry.get(kind);
|
|
296
352
|
if (!plugin) {
|
|
297
353
|
this.log(`⚠️ No plugin registered for kind: ${kind}`);
|
|
@@ -300,16 +356,65 @@ export class AgentTraverser {
|
|
|
300
356
|
try {
|
|
301
357
|
const file = this.project.addSourceFileAtPath(sourcePath);
|
|
302
358
|
const detected = plugin.detect(file);
|
|
303
|
-
|
|
304
|
-
|
|
359
|
+
// Tier 1: `isDefaultExport` flag set by the plugin. Populated by
|
|
360
|
+
// `export default new LuaX({...})` and `export default defineX({...})`
|
|
361
|
+
// (inline shapes that `detectDefaultExport` can see directly).
|
|
362
|
+
let defaultMatch = opts.viaDefaultImport
|
|
363
|
+
? detected.find((d) => d.isDefaultExport)
|
|
364
|
+
: undefined;
|
|
365
|
+
// Tier 2: the `export default <identifier>` shape. Plugins only
|
|
366
|
+
// flag `isDefaultExport` when the export assignment's expression
|
|
367
|
+
// is itself a `new X({...})` / `defineX({...})` — they don't
|
|
368
|
+
// chase an Identifier back to its declaration. When the user
|
|
369
|
+
// wrote `const chosen = new LuaX({...}); export default chosen`,
|
|
370
|
+
// `chosen` has `exportName === 'chosen'` and `isDefaultExport`
|
|
371
|
+
// is false, but semantically it IS the default export.
|
|
372
|
+
//
|
|
373
|
+
// We resolve this at match time by inspecting the file's
|
|
374
|
+
// ExportAssignments: if one points at an Identifier whose name
|
|
375
|
+
// equals a detected primitive's `exportName`, that primitive is
|
|
376
|
+
// the default export by reference.
|
|
377
|
+
if (opts.viaDefaultImport && !defaultMatch) {
|
|
378
|
+
for (const assign of file.getExportAssignments()) {
|
|
379
|
+
if (assign.isExportEquals())
|
|
380
|
+
continue;
|
|
381
|
+
const expr = assign.getExpression();
|
|
382
|
+
if (!Node.isIdentifier(expr))
|
|
383
|
+
continue;
|
|
384
|
+
const targetName = expr.getText();
|
|
385
|
+
defaultMatch = detected.find((d) => d.exportName === targetName);
|
|
386
|
+
if (defaultMatch)
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const match = defaultMatch ??
|
|
391
|
+
detected.find((d) => d.exportName === refName ||
|
|
392
|
+
d.name === refName) ??
|
|
393
|
+
(detected.length === 1 ? detected[0] : null);
|
|
305
394
|
if (!match) {
|
|
306
|
-
|
|
395
|
+
// Visible by default, not gated on `debug`. The agent referenced
|
|
396
|
+
// a primitive we located on disk but the plugin couldn't find one
|
|
397
|
+
// in that file — the primitive silently drops out of the manifest
|
|
398
|
+
// unless the user knows to look, which is exactly the kind of
|
|
399
|
+
// silence LUA-221 taught us to eliminate.
|
|
400
|
+
console.warn(formatSarifWarning({
|
|
401
|
+
ruleId: 'lua/missing-primitive-declaration',
|
|
402
|
+
filePath: sourcePath,
|
|
403
|
+
message: `agent references ${kind} "${refName}" but ${path.basename(sourcePath)} ` +
|
|
404
|
+
`does not define a matching primitive`,
|
|
405
|
+
hint: `export a named ${plugin.displayName.toLowerCase()} declaration as "${refName}", ` +
|
|
406
|
+
`or adjust the import so it points to the file that does`,
|
|
407
|
+
}));
|
|
307
408
|
return null;
|
|
308
409
|
}
|
|
309
410
|
return match;
|
|
310
411
|
}
|
|
311
412
|
catch (error) {
|
|
312
|
-
|
|
413
|
+
console.warn(formatSarifWarning({
|
|
414
|
+
ruleId: 'lua/missing-primitive-declaration',
|
|
415
|
+
filePath: sourcePath,
|
|
416
|
+
message: `error extracting ${kind} "${refName}": ${error instanceof Error ? error.message : String(error)}`,
|
|
417
|
+
}));
|
|
313
418
|
}
|
|
314
419
|
return null;
|
|
315
420
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-traverser.js","sourceRoot":"","sources":["../../src/compiler/agent-traverser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,OAAO,EAAc,IAAI,
|
|
1
|
+
{"version":3,"file":"agent-traverser.js","sourceRoot":"","sources":["../../src/compiler/agent-traverser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,OAAO,EAAc,IAAI,EAA+C,MAAM,UAAU,CAAC;AAClG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,GAGnB,MAAM,+BAA+B,CAAC;AA2CvC;;;GAGG;AACH,MAAM,eAAe,GAA0B;IAC7C,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE;IAChE,EAAE,IAAI,EAAE,SAAS,EAAE,cAA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ACV,kBAAkB,CAAC;oBACjB,MAAM,EAAE,mCAAmC;oBAC3C,QAAQ,EAAE,UAAU;oBACpB,OAAO,EACL,oBAAoB,IAAI,KAAK,OAAO,SAAS,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG;wBACzE,sCAAsC;oBACxC,IAAI,EACF,kBAAkB,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,oBAAoB,OAAO,KAAK;wBAClF,yDAAyD;iBAC5D,CAAC,CACH,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CACV,kBAAkB,CAAC;gBACjB,MAAM,EAAE,mCAAmC;gBAC3C,QAAQ,EAAE,UAAU;gBACpB,OAAO,EAAE,oBAAoB,IAAI,KAAK,OAAO,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aAC5G,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -13,6 +13,22 @@ export declare class Compiler {
|
|
|
13
13
|
private project;
|
|
14
14
|
private options;
|
|
15
15
|
private bundler;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute paths of source files loaded by `AgentTraverser` that live
|
|
18
|
+
* outside `rootDir` but inside the containing workspace.
|
|
19
|
+
*
|
|
20
|
+
* Populated during `scanForPrimitives()` and consumed by
|
|
21
|
+
* `collectProjectFiles()` so cross-root files are included in the
|
|
22
|
+
* backup manifest. See BAC-69 and [workspace.ts](src/compiler/utils/workspace.ts).
|
|
23
|
+
*/
|
|
24
|
+
private externalWorkspaceFiles;
|
|
25
|
+
/**
|
|
26
|
+
* Memoized workspace root. `findWorkspaceRoot` walks the tree + hits FS
|
|
27
|
+
* markers (pnpm-workspace.yaml, lerna.json, etc.) — cheap but not free,
|
|
28
|
+
* and called from three different hot paths (scan, collect, store).
|
|
29
|
+
* Populated lazily via `getWorkspaceRoot()`.
|
|
30
|
+
*/
|
|
31
|
+
private _workspaceRoot?;
|
|
16
32
|
constructor(options: CompilerOptions);
|
|
17
33
|
/**
|
|
18
34
|
* Run the compilation.
|
|
@@ -27,6 +43,22 @@ export declare class Compiler {
|
|
|
27
43
|
* Also caches the agent info for manifest creation (avoids re-traversing).
|
|
28
44
|
*/
|
|
29
45
|
private scanForPrimitives;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the containing workspace root for this compilation, memoized
|
|
48
|
+
* for the lifetime of the Compiler instance. Returns the normalized
|
|
49
|
+
* absolute path; for standalone agents it's identical to `rootDir`.
|
|
50
|
+
*/
|
|
51
|
+
private getWorkspaceRoot;
|
|
52
|
+
/**
|
|
53
|
+
* Return absolute paths of files the traverser loaded that live outside
|
|
54
|
+
* `rootDir` but inside the containing workspace.
|
|
55
|
+
*
|
|
56
|
+
* We deliberately skip:
|
|
57
|
+
* - Files under `rootDir` (the normal `collectProjectFiles` walker handles them)
|
|
58
|
+
* - Files inside `node_modules` (third-party; restored via `npm install`)
|
|
59
|
+
* - Files outside the detected workspace root (not our code)
|
|
60
|
+
*/
|
|
61
|
+
private collectExternalWorkspaceFiles;
|
|
30
62
|
/**
|
|
31
63
|
* Fallback discovery: scan all source files for primitives when no LuaAgent is found.
|
|
32
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH,OAAO,EAEL,eAAe,EACf,iBAAiB,EAQlB,MAAM,YAAY,CAAC;AAGpB,cAAc,YAAY,CAAC;AAM3B,qBAAa,QAAQ;IACnB,OAAO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