acp-kernel 0.0.65-pr.260.115 → 0.0.65-pr.261.116
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/README.md +0 -21
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -122
- package/dist/index.js.map +1 -1
- package/dist/packs/builtin.d.ts +5 -0
- package/dist/packs/builtin.d.ts.map +1 -0
- package/dist/packs/dir.d.ts +14 -0
- package/dist/packs/dir.d.ts.map +1 -0
- package/dist/packs/resolver.d.ts +25 -0
- package/dist/packs/resolver.d.ts.map +1 -0
- package/dist/packs/sanitize.d.ts +10 -0
- package/dist/packs/sanitize.d.ts.map +1 -0
- package/dist/packs/types.d.ts +65 -0
- package/dist/packs/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/packs.d.ts +0 -74
- package/dist/packs.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -105,7 +105,6 @@ live-recomputed tags, use `renderVisibleRefs` directly.
|
|
|
105
105
|
| `applyMessageFilters` | Pluggable message-filter framework |
|
|
106
106
|
| `resolveTransformChannel` | Channel-selection policy: an explicit preference wins; the default is the wire channel only when the caller reports it viable |
|
|
107
107
|
| `applySectionOverrides` / `cloneWithDescriptions` / `applyAcpToolOverrides` | Prompt/tool *surface* customization (see below) |
|
|
108
|
-
| `sanitizePackSurface` / `createPackResolver` / `defaultPackSources` | Prompt packs: named, swappable surface presets resolved over pluggable sources (see below) |
|
|
109
108
|
|
|
110
109
|
### Prompt/tool surface configuration
|
|
111
110
|
|
|
@@ -132,26 +131,6 @@ safe to customize freely; these helpers implement that:
|
|
|
132
131
|
`input_schema`, openai `function.parameters`, responses flat
|
|
133
132
|
`parameters`). Shared tool constants are never mutated.
|
|
134
133
|
|
|
135
|
-
#### Prompt packs
|
|
136
|
-
|
|
137
|
-
Named, swappable surface configurations layered on top of the primitives above:
|
|
138
|
-
|
|
139
|
-
- `Pack` / `PackSurface` / `PackSource` / `PackResolver` — contracts. Sources are
|
|
140
|
-
consulted in resolver order; first hit wins; sources must be per-turn safe
|
|
141
|
-
(sync, no throw).
|
|
142
|
-
- `sanitizePackSurface(raw)` — turns a raw pack JSON into a sanitized
|
|
143
|
-
`PackSurface`: tri-state for section keys (`string` replace / `null` remove /
|
|
144
|
-
omitted keep), per-tool description + paramDescriptions. Malformed values are
|
|
145
|
-
dropped. The opaque `adapters.<hostId>` record passes through for host-side
|
|
146
|
-
validation.
|
|
147
|
-
- Builtins: `default` (identity) and `lean` (one-line tool descriptions;
|
|
148
|
-
host-specific trims ride under `adapters.<hostId>` as data).
|
|
149
|
-
- `createDirPackSource(id, dir)` serves `<dir>/<name>.json` files;
|
|
150
|
-
`defaultPackSources({ projectDir, userDirs })` assembles project > user >
|
|
151
|
-
builtin. Directory paths are host policy.
|
|
152
|
-
- Pack *selection* (which name is active per config cascade) stays adapter-side;
|
|
153
|
-
the kernel only resolves names.
|
|
154
|
-
|
|
155
134
|
### Nudge system
|
|
156
135
|
|
|
157
136
|
The nudge system tells the model *when* to compress. It implements:
|
package/dist/index.d.ts
CHANGED
|
@@ -18,8 +18,13 @@ export { defaultPrompts, resolvePrompts } from "./prompts.js";
|
|
|
18
18
|
export type { Prompts, ResolvePromptsOptions } from "./prompts.js";
|
|
19
19
|
export { applySectionOverrides, cloneWithDescriptions, applyAcpToolOverrides, } from "./surface-config.js";
|
|
20
20
|
export type { SectionOverride, CompressPromptSections, ToolPromptOverrides, ToolPrompts, AcpToolLike, } from "./surface-config.js";
|
|
21
|
-
export {
|
|
22
|
-
export
|
|
21
|
+
export { sanitizePackSurface } from "./packs/sanitize.js";
|
|
22
|
+
export { isValidPackName } from "./packs/types.js";
|
|
23
|
+
export type { PromptPackFile, PackSurface, Pack, PackSource } from "./packs/types.js";
|
|
24
|
+
export { defaultPack, leanPack, builtinSource } from "./packs/builtin.js";
|
|
25
|
+
export { createDirPackSource } from "./packs/dir.js";
|
|
26
|
+
export { createPackResolver, defaultPackSources } from "./packs/resolver.js";
|
|
27
|
+
export type { PackResolver, DefaultPackSourcesOptions } from "./packs/resolver.js";
|
|
23
28
|
export { truncateLargeToolOutputs } from "./truncate-tools.js";
|
|
24
29
|
export type { TruncateOptions, TruncateResult } from "./truncate-tools.js";
|
|
25
30
|
export { parseBlockIdArg, findBlocksOverlappingMessages, findActiveAncestor, deactivateBlock, buildRestoredContentPreview, collectBlockContent, } from "./decompress.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM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AO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3031,65 +3031,94 @@ function countOccurrences(haystack, needle) {
|
|
|
3031
3031
|
return count;
|
|
3032
3032
|
}
|
|
3033
3033
|
|
|
3034
|
-
// src/packs.ts
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3034
|
+
// src/packs/sanitize.ts
|
|
3035
|
+
var PROMPT_RULE_KEYS = [
|
|
3036
|
+
"compressPhilosophy",
|
|
3037
|
+
"howToCompressRules",
|
|
3038
|
+
"tier2DistillRules",
|
|
3039
|
+
"tier3CondenseRules"
|
|
3040
|
+
];
|
|
3041
|
+
var COMPRESS_SECTION_KEYS = [
|
|
3042
|
+
"acpTags",
|
|
3043
|
+
"tools",
|
|
3044
|
+
"summariesInContext",
|
|
3045
|
+
"textProtocol",
|
|
3046
|
+
"textTools",
|
|
3047
|
+
"functionTools"
|
|
3048
|
+
];
|
|
3049
|
+
var NUDGE_SECTION_KEYS = [
|
|
3050
|
+
"efficiencyNote",
|
|
3051
|
+
"emergencyHeader",
|
|
3052
|
+
"t2Guidance",
|
|
3053
|
+
"t3Guidance"
|
|
3054
|
+
];
|
|
3055
|
+
function pickSection(raw, keys) {
|
|
3056
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
3044
3057
|
const out = {};
|
|
3045
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return out;
|
|
3046
3058
|
for (const key of keys) {
|
|
3047
|
-
const
|
|
3048
|
-
if (typeof
|
|
3049
|
-
else if (v === null) out[key] = null;
|
|
3059
|
+
const value = raw[key];
|
|
3060
|
+
if (typeof value === "string" || value === null) out[key] = value;
|
|
3050
3061
|
}
|
|
3051
|
-
return out;
|
|
3062
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
3052
3063
|
}
|
|
3053
|
-
function
|
|
3054
|
-
if (!raw) return
|
|
3064
|
+
function pickToolPrompts(raw) {
|
|
3065
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
3066
|
+
const out = {};
|
|
3067
|
+
for (const [tool, value] of Object.entries(raw)) {
|
|
3068
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
3069
|
+
const src = value;
|
|
3070
|
+
const entry = {};
|
|
3071
|
+
if (typeof src.description === "string")
|
|
3072
|
+
entry.description = src.description;
|
|
3073
|
+
if (src.paramDescriptions && typeof src.paramDescriptions === "object" && !Array.isArray(src.paramDescriptions)) {
|
|
3074
|
+
const params = {};
|
|
3075
|
+
for (const [name, description] of Object.entries(
|
|
3076
|
+
src.paramDescriptions
|
|
3077
|
+
)) {
|
|
3078
|
+
if (typeof description === "string") params[name] = description;
|
|
3079
|
+
}
|
|
3080
|
+
if (Object.keys(params).length > 0) entry.paramDescriptions = params;
|
|
3081
|
+
}
|
|
3082
|
+
if (Object.keys(entry).length > 0) out[tool] = entry;
|
|
3083
|
+
}
|
|
3084
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
3085
|
+
}
|
|
3086
|
+
function sanitizePackSurface(pack) {
|
|
3087
|
+
if (!pack || typeof pack !== "object" || Array.isArray(pack)) return {};
|
|
3088
|
+
const surface = {};
|
|
3055
3089
|
const prompts = {};
|
|
3056
|
-
const rawPrompts =
|
|
3090
|
+
const rawPrompts = pack.prompts;
|
|
3057
3091
|
if (rawPrompts && typeof rawPrompts === "object" && !Array.isArray(rawPrompts)) {
|
|
3058
|
-
for (const
|
|
3059
|
-
const
|
|
3060
|
-
if (typeof
|
|
3061
|
-
|
|
3062
|
-
}
|
|
3063
|
-
const toolPrompts = {};
|
|
3064
|
-
const rawTools = raw.toolPrompts;
|
|
3065
|
-
if (rawTools && typeof rawTools === "object" && !Array.isArray(rawTools)) {
|
|
3066
|
-
for (const [name, value] of Object.entries(rawTools)) {
|
|
3067
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
3068
|
-
const ov = value;
|
|
3069
|
-
const out = {};
|
|
3070
|
-
if (typeof ov.description === "string") out.description = ov.description;
|
|
3071
|
-
if (ov.paramDescriptions && typeof ov.paramDescriptions === "object" && !Array.isArray(ov.paramDescriptions)) {
|
|
3072
|
-
const params = {};
|
|
3073
|
-
for (const [p, d] of Object.entries(ov.paramDescriptions)) {
|
|
3074
|
-
if (typeof d === "string") params[p] = d;
|
|
3075
|
-
}
|
|
3076
|
-
if (Object.keys(params).length > 0) out.paramDescriptions = params;
|
|
3077
|
-
}
|
|
3078
|
-
if (Object.keys(out).length > 0) toolPrompts[name] = out;
|
|
3092
|
+
for (const key of PROMPT_RULE_KEYS) {
|
|
3093
|
+
const value = rawPrompts[key];
|
|
3094
|
+
if (typeof value === "string")
|
|
3095
|
+
prompts[key] = value;
|
|
3079
3096
|
}
|
|
3080
3097
|
}
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3098
|
+
if (Object.keys(prompts).length > 0) surface.prompts = prompts;
|
|
3099
|
+
const promptSections = pickSection(
|
|
3100
|
+
pack.promptSections,
|
|
3101
|
+
COMPRESS_SECTION_KEYS
|
|
3102
|
+
);
|
|
3103
|
+
if (promptSections)
|
|
3104
|
+
surface.promptSections = promptSections;
|
|
3105
|
+
const nudgeSections = pickSection(pack.nudgeSections, NUDGE_SECTION_KEYS);
|
|
3106
|
+
if (nudgeSections)
|
|
3107
|
+
surface.nudgeSections = nudgeSections;
|
|
3108
|
+
const toolPrompts = pickToolPrompts(pack.toolPrompts);
|
|
3109
|
+
if (toolPrompts) surface.toolPrompts = toolPrompts;
|
|
3110
|
+
if (pack.adapters && typeof pack.adapters === "object" && !Array.isArray(pack.adapters)) {
|
|
3111
|
+
surface.adapters = { ...pack.adapters };
|
|
3090
3112
|
}
|
|
3091
3113
|
return surface;
|
|
3092
3114
|
}
|
|
3115
|
+
|
|
3116
|
+
// src/packs/types.ts
|
|
3117
|
+
function isValidPackName(name) {
|
|
3118
|
+
return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name) && !name.includes("..");
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
// src/packs/builtin.ts
|
|
3093
3122
|
var defaultPack = {
|
|
3094
3123
|
name: "default",
|
|
3095
3124
|
version: "1.0.0",
|
|
@@ -3097,67 +3126,40 @@ var defaultPack = {
|
|
|
3097
3126
|
source: "builtin:default",
|
|
3098
3127
|
surface: {}
|
|
3099
3128
|
};
|
|
3100
|
-
var
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
startId: "Inclusive first mNNNNN or bN ref.",
|
|
3106
|
-
endId: "Inclusive last mNNNNN or bN ref.",
|
|
3107
|
-
summary: "Self-contained replacement preserving exact technical details.",
|
|
3108
|
-
topic: "Short label; a per-range label overrides the top-level fallback.",
|
|
3109
|
-
summaryMaxChars: "Optional summary length limit override."
|
|
3110
|
-
}
|
|
3111
|
-
},
|
|
3112
|
-
decompress: {
|
|
3113
|
-
description: "Restore compressed content by block id (b5) or message ref; block mode writes to a file by default, inline: true returns small content inline."
|
|
3114
|
-
},
|
|
3115
|
-
search_context: {
|
|
3116
|
-
description: "Search compressed summaries and historical messages by keyword; returns refs, sizes, previews."
|
|
3117
|
-
},
|
|
3118
|
-
acp_status: {
|
|
3119
|
-
description: "Context usage overview, compressible ranges, block drilldown."
|
|
3120
|
-
}
|
|
3121
|
-
};
|
|
3129
|
+
var LEAN_ACP_TAGS = [
|
|
3130
|
+
"ACP TAGS",
|
|
3131
|
+
"",
|
|
3132
|
+
"User/tool messages carry hidden \\x3cacp\\x3e refs such as m00123. Never echo the XML tags; use only refs in ACP tool calls."
|
|
3133
|
+
].join("\n");
|
|
3122
3134
|
var leanPack = {
|
|
3123
3135
|
name: "lean",
|
|
3124
3136
|
version: "1.0.0",
|
|
3125
|
-
description: "Token-lean surface: one-line tool descriptions
|
|
3137
|
+
description: "Token-lean surface adapted from kunkun9527/billion-context-pi-lean: compact ACP-tags section plus one-line tool descriptions for the four ACP tools. Compression rules stay default (load-bearing, delivered by the builders and nudges); host-specific lean surfaces ride under adapters.<hostId>.",
|
|
3126
3138
|
source: "builtin:lean",
|
|
3127
3139
|
surface: {
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
].join("\n"),
|
|
3142
|
-
summariesInContext: null,
|
|
3143
|
-
tools: null,
|
|
3144
|
-
philosophy: null,
|
|
3145
|
-
whenToCompress: null,
|
|
3146
|
-
whenNotToCompress: null,
|
|
3147
|
-
howToCompress: null,
|
|
3148
|
-
multiTierIntro: null,
|
|
3149
|
-
tier2: null,
|
|
3150
|
-
tier3: null,
|
|
3151
|
-
decompressPhilosophy: null,
|
|
3152
|
-
contextBreakdown: null,
|
|
3153
|
-
throttleRetry: null
|
|
3154
|
-
},
|
|
3155
|
-
toolExtras: {
|
|
3156
|
-
compress: { promptSnippet: "", promptGuidelines: [] },
|
|
3157
|
-
decompress: { promptSnippet: "", promptGuidelines: [] },
|
|
3158
|
-
search_context: { promptSnippet: "", promptGuidelines: [] },
|
|
3159
|
-
acp_status: { promptSnippet: "", promptGuidelines: [] }
|
|
3140
|
+
promptSections: {
|
|
3141
|
+
acpTags: LEAN_ACP_TAGS
|
|
3142
|
+
},
|
|
3143
|
+
toolPrompts: {
|
|
3144
|
+
compress: {
|
|
3145
|
+
description: "Replace consumed conversation ranges with self-contained summaries using mNNNNN or bN refs.",
|
|
3146
|
+
paramDescriptions: {
|
|
3147
|
+
content: "Direct array; no JSON strings/nesting/mix.",
|
|
3148
|
+
startId: "Inclusive first mNNNNN or bN ref.",
|
|
3149
|
+
endId: "Inclusive last mNNNNN or bN ref.",
|
|
3150
|
+
summary: "Self-contained replacement preserving exact technical details.",
|
|
3151
|
+
topic: "Short label; a per-range label overrides the top-level fallback.",
|
|
3152
|
+
summaryMaxChars: "Optional summary length limit override."
|
|
3160
3153
|
}
|
|
3154
|
+
},
|
|
3155
|
+
decompress: {
|
|
3156
|
+
description: "Restore compressed content by block id (b5) or message ref; one tier up by default, full:true restores originals, toFile writes to a file instead of context."
|
|
3157
|
+
},
|
|
3158
|
+
search_context: {
|
|
3159
|
+
description: "Search compressed summaries and historical messages by keyword; returns refs, sizes, previews."
|
|
3160
|
+
},
|
|
3161
|
+
acp_status: {
|
|
3162
|
+
description: "Context usage overview, compressible ranges, block drilldown."
|
|
3161
3163
|
}
|
|
3162
3164
|
}
|
|
3163
3165
|
}
|
|
@@ -3175,6 +3177,10 @@ var builtinSource = {
|
|
|
3175
3177
|
return Object.values(BUILTIN_REGISTRY);
|
|
3176
3178
|
}
|
|
3177
3179
|
};
|
|
3180
|
+
|
|
3181
|
+
// src/packs/dir.ts
|
|
3182
|
+
import { readFileSync, readdirSync } from "fs";
|
|
3183
|
+
import * as path from "path";
|
|
3178
3184
|
function readPackFile(file) {
|
|
3179
3185
|
try {
|
|
3180
3186
|
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
@@ -3184,22 +3190,21 @@ function readPackFile(file) {
|
|
|
3184
3190
|
}
|
|
3185
3191
|
}
|
|
3186
3192
|
function createDirPackSource(id, dir) {
|
|
3187
|
-
const resolve = (name) => {
|
|
3188
|
-
if (!isValidPackName(name)) return null;
|
|
3189
|
-
const file = path.join(dir, `${name}.json`);
|
|
3190
|
-
const raw = readPackFile(file);
|
|
3191
|
-
if (!raw) return null;
|
|
3192
|
-
return {
|
|
3193
|
-
name,
|
|
3194
|
-
version: typeof raw.version === "string" ? raw.version : void 0,
|
|
3195
|
-
description: typeof raw.description === "string" ? raw.description : void 0,
|
|
3196
|
-
surface: sanitizePackSurface(raw),
|
|
3197
|
-
source: `file:${file}`
|
|
3198
|
-
};
|
|
3199
|
-
};
|
|
3200
3193
|
return {
|
|
3201
3194
|
id,
|
|
3202
|
-
resolve
|
|
3195
|
+
resolve(name) {
|
|
3196
|
+
if (!isValidPackName(name)) return null;
|
|
3197
|
+
const file = path.join(dir, `${name}.json`);
|
|
3198
|
+
const raw = readPackFile(file);
|
|
3199
|
+
if (!raw) return null;
|
|
3200
|
+
return {
|
|
3201
|
+
name,
|
|
3202
|
+
version: typeof raw.version === "string" ? raw.version : void 0,
|
|
3203
|
+
description: typeof raw.description === "string" ? raw.description : void 0,
|
|
3204
|
+
surface: sanitizePackSurface(raw),
|
|
3205
|
+
source: `file:${file}`
|
|
3206
|
+
};
|
|
3207
|
+
},
|
|
3203
3208
|
list() {
|
|
3204
3209
|
let names;
|
|
3205
3210
|
try {
|
|
@@ -3208,14 +3213,16 @@ function createDirPackSource(id, dir) {
|
|
|
3208
3213
|
return [];
|
|
3209
3214
|
}
|
|
3210
3215
|
const out = [];
|
|
3211
|
-
for (const
|
|
3212
|
-
const pack = resolve(
|
|
3216
|
+
for (const file of names) {
|
|
3217
|
+
const pack = this.resolve(file.slice(0, -5));
|
|
3213
3218
|
if (pack) out.push(pack);
|
|
3214
3219
|
}
|
|
3215
3220
|
return out;
|
|
3216
3221
|
}
|
|
3217
3222
|
};
|
|
3218
3223
|
}
|
|
3224
|
+
|
|
3225
|
+
// src/packs/resolver.ts
|
|
3219
3226
|
function createPackResolver(sources) {
|
|
3220
3227
|
return {
|
|
3221
3228
|
sources,
|
|
@@ -3242,9 +3249,13 @@ function createPackResolver(sources) {
|
|
|
3242
3249
|
}
|
|
3243
3250
|
};
|
|
3244
3251
|
}
|
|
3245
|
-
function defaultPackSources(
|
|
3246
|
-
const sources = [
|
|
3247
|
-
|
|
3252
|
+
function defaultPackSources(options = {}) {
|
|
3253
|
+
const sources = [];
|
|
3254
|
+
if (options.projectDir)
|
|
3255
|
+
sources.push(createDirPackSource("project", options.projectDir));
|
|
3256
|
+
let i = 0;
|
|
3257
|
+
for (const dir of options.userDirs ?? [])
|
|
3258
|
+
sources.push(createDirPackSource(`user${i++}`, dir));
|
|
3248
3259
|
sources.push(builtinSource);
|
|
3249
3260
|
return sources;
|
|
3250
3261
|
}
|