@bdsqqq/pi 0.0.1 → 0.0.1772749067-g76a42af
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/core/interpolate.js +12 -3
- package/package.json +15 -4
package/dist/core/interpolate.js
CHANGED
|
@@ -105,7 +105,10 @@ function extractRefs(s, knownVars) {
|
|
|
105
105
|
const refs = [];
|
|
106
106
|
const re = /\{(\w+)\}/g;
|
|
107
107
|
let m;
|
|
108
|
-
while ((m = re.exec(s)) !== null)
|
|
108
|
+
while ((m = re.exec(s)) !== null) {
|
|
109
|
+
const cap = m[1];
|
|
110
|
+
if (cap !== void 0 && knownVars.has(cap)) refs.push(cap);
|
|
111
|
+
}
|
|
109
112
|
return refs;
|
|
110
113
|
}
|
|
111
114
|
/** collect all variable dependencies for a single definition. */
|
|
@@ -141,7 +144,10 @@ function topoSort(defs) {
|
|
|
141
144
|
}
|
|
142
145
|
/** substitute already-resolved vars into a string. */
|
|
143
146
|
function subVars(s, resolved) {
|
|
144
|
-
return s.replace(/\{(\w+)\}/g, (match, key) =>
|
|
147
|
+
return s.replace(/\{(\w+)\}/g, (match, key) => {
|
|
148
|
+
const val = resolved[key];
|
|
149
|
+
return val !== void 0 ? val : match;
|
|
150
|
+
});
|
|
145
151
|
}
|
|
146
152
|
/** resolve a single variable definition to a string value. */
|
|
147
153
|
function resolveVariable(def, resolved, runtimeVars, configDir) {
|
|
@@ -207,7 +213,10 @@ function interpolatePromptVars(prompt, cwd, extra, variables) {
|
|
|
207
213
|
const configDir = resolveConfigDir();
|
|
208
214
|
const order = topoSort(merged);
|
|
209
215
|
const resolved = {};
|
|
210
|
-
for (const name of order)
|
|
216
|
+
for (const name of order) {
|
|
217
|
+
const def = merged[name];
|
|
218
|
+
if (def) resolved[name] = resolveVariable(def, resolved, runtimeVars, configDir);
|
|
219
|
+
}
|
|
211
220
|
const dropKeys = [];
|
|
212
221
|
const filled = {};
|
|
213
222
|
for (const [key, value] of Object.entries(resolved)) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bdsqqq/pi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1772749067-g76a42af",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "extensions and core utilities for pi-coding-agent",
|
|
6
|
-
"keywords": [
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package"
|
|
8
|
+
],
|
|
7
9
|
"license": "MIT",
|
|
8
|
-
"
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/bdsqqq/dots.git",
|
|
13
|
+
"directory": "user/pi"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
9
18
|
"exports": {
|
|
10
19
|
"./extensions": {
|
|
11
20
|
"types": "./dist/extensions.d.ts",
|
|
@@ -21,7 +30,9 @@
|
|
|
21
30
|
}
|
|
22
31
|
},
|
|
23
32
|
"pi": {
|
|
24
|
-
"extensions": [
|
|
33
|
+
"extensions": [
|
|
34
|
+
"./dist/extensions"
|
|
35
|
+
]
|
|
25
36
|
},
|
|
26
37
|
"workspaces": {
|
|
27
38
|
"packages": [
|