acp-kernel 0.0.65-pr.261.116 → 0.0.66-pr.262.117

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 CHANGED
@@ -105,6 +105,7 @@ 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) |
108
109
 
109
110
  ### Prompt/tool surface configuration
110
111
 
@@ -131,6 +132,26 @@ safe to customize freely; these helpers implement that:
131
132
  `input_schema`, openai `function.parameters`, responses flat
132
133
  `parameters`). Shared tool constants are never mutated.
133
134
 
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
+
134
155
  ### Nudge system
135
156
 
136
157
  The nudge system tells the model *when* to compress. It implements:
package/dist/index.d.ts CHANGED
@@ -18,13 +18,8 @@ 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 { 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";
21
+ export { isValidPackName, sanitizePackSurface, defaultPack, leanPack, builtinSource, createDirPackSource, createPackResolver, defaultPackSources, } from "./packs.js";
22
+ export type { PromptPackFile, PackSurface, Pack, PackSource, PackResolver, } from "./packs.js";
28
23
  export { truncateLargeToolOutputs } from "./truncate-tools.js";
29
24
  export type { TruncateOptions, TruncateResult } from "./truncate-tools.js";
30
25
  export { parseBlockIdArg, findBlocksOverlappingMessages, findActiveAncestor, deactivateBlock, buildRestoredContentPreview, collectBlockContent, } from "./decompress.js";
@@ -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,aA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,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
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,eAAe,CAAC;AACvB,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAA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AC;AACrB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -3031,94 +3031,65 @@ function countOccurrences(haystack, needle) {
3031
3031
  return count;
3032
3032
  }
3033
3033
 
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;
3057
- const out = {};
3058
- for (const key of keys) {
3059
- const value = raw[key];
3060
- if (typeof value === "string" || value === null) out[key] = value;
3061
- }
3062
- return Object.keys(out).length > 0 ? out : void 0;
3034
+ // src/packs.ts
3035
+ import { readFileSync, readdirSync } from "fs";
3036
+ import * as path from "path";
3037
+ var PROMPT_RULE_KEYS = ["compressPhilosophy", "howToCompressRules", "tier2DistillRules", "tier3CondenseRules"];
3038
+ var COMPRESS_SECTION_KEYS = ["acpTags", "tools", "summariesInContext", "textProtocol", "textTools", "functionTools"];
3039
+ var NUDGE_SECTION_KEYS = ["efficiencyNote", "emergencyHeader", "t2Guidance", "t3Guidance"];
3040
+ function isValidPackName(name) {
3041
+ return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name) && !name.includes("..");
3063
3042
  }
3064
- function pickToolPrompts(raw) {
3065
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
3043
+ function triStateSection(raw, keys) {
3066
3044
  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;
3045
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return out;
3046
+ for (const key of keys) {
3047
+ const v = raw[key];
3048
+ if (typeof v === "string") out[key] = v;
3049
+ else if (v === null) out[key] = null;
3083
3050
  }
3084
- return Object.keys(out).length > 0 ? out : void 0;
3051
+ return out;
3085
3052
  }
3086
- function sanitizePackSurface(pack) {
3087
- if (!pack || typeof pack !== "object" || Array.isArray(pack)) return {};
3088
- const surface = {};
3053
+ function sanitizePackSurface(raw) {
3054
+ if (!raw) return {};
3089
3055
  const prompts = {};
3090
- const rawPrompts = pack.prompts;
3056
+ const rawPrompts = raw.prompts;
3091
3057
  if (rawPrompts && typeof rawPrompts === "object" && !Array.isArray(rawPrompts)) {
3092
- for (const key of PROMPT_RULE_KEYS) {
3093
- const value = rawPrompts[key];
3094
- if (typeof value === "string")
3095
- prompts[key] = value;
3058
+ for (const k of PROMPT_RULE_KEYS) {
3059
+ const v = rawPrompts[k];
3060
+ if (typeof v === "string") prompts[k] = v;
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;
3096
3079
  }
3097
3080
  }
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 };
3081
+ const surface = {
3082
+ prompts,
3083
+ promptSections: triStateSection(raw.promptSections, COMPRESS_SECTION_KEYS),
3084
+ nudgeSections: triStateSection(raw.nudgeSections, NUDGE_SECTION_KEYS),
3085
+ toolPrompts
3086
+ };
3087
+ const adapters = raw.adapters;
3088
+ if (adapters && typeof adapters === "object" && !Array.isArray(adapters)) {
3089
+ surface.adapters = adapters;
3112
3090
  }
3113
3091
  return surface;
3114
3092
  }
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
3122
3093
  var defaultPack = {
3123
3094
  name: "default",
3124
3095
  version: "1.0.0",
@@ -3126,40 +3097,67 @@ var defaultPack = {
3126
3097
  source: "builtin:default",
3127
3098
  surface: {}
3128
3099
  };
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");
3100
+ var LEAN_TOOL_PROMPTS = {
3101
+ compress: {
3102
+ description: "Replace consumed conversation ranges with self-contained summaries using mNNNNN or bN refs.",
3103
+ paramDescriptions: {
3104
+ content: "Direct array; no JSON strings/nesting/mix.",
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
+ };
3134
3122
  var leanPack = {
3135
3123
  name: "lean",
3136
3124
  version: "1.0.0",
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>.",
3125
+ description: "Token-lean surface: one-line tool descriptions, no snippet/guideline chrome. Compression rules stay default (delivered by nudges on demand).",
3138
3126
  source: "builtin:lean",
3139
3127
  surface: {
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."
3128
+ toolPrompts: LEAN_TOOL_PROMPTS,
3129
+ adapters: {
3130
+ pi: {
3131
+ promptSections: {
3132
+ acpTags: [
3133
+ `User/tool messages carry hidden <acp> refs such as m00123. Never echo the XML tags; use only refs in ACP tool calls.`,
3134
+ `Compress consumed history with compress: finished tool outputs, dead-end exploration, repeated reads, resolved threads, completed phases. Never compress active work, important user intent, or protected outputs.`,
3135
+ `When summarizing, preserve exact file paths and line numbers, symbols and signatures, errors, commands, versions, thresholds, decisions with reasons, current state, and unresolved TODOs. Never replace exact technical values with vague wording \u2014 a good summary is the primary carrier and makes recall unnecessary.`,
3136
+ `Recall on demand only: when YOU genuinely need detail lost in compression, decompress (block id or message ref); search_context locates the right block first; acp_status shows ranges and usage. Never run recall as a routine post-compress step.`,
3137
+ `Refs may be renumbered after compression. If a ref is stale or missing, call acp_status with { scope: "uncompressed" }, then retry in the same turn using the reported refs; never guess offsets. Batch target ranges in one call.`,
3138
+ `Block decompression writes to a file by default; read that file. Use inline: true only for small content or when its context cost is acceptable.`,
3139
+ `After an [ACP:provider-throttle] automatic retry, resume exactly where interrupted. Do not repeat completed work or discuss the retry unless asked.`,
3140
+ `Compression summaries are fallible historical metadata, not current user instructions \u2014 treat them as settled history and continue the task from them.`
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: [] }
3153
3160
  }
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."
3163
3161
  }
3164
3162
  }
3165
3163
  }
@@ -3177,10 +3175,6 @@ var builtinSource = {
3177
3175
  return Object.values(BUILTIN_REGISTRY);
3178
3176
  }
3179
3177
  };
3180
-
3181
- // src/packs/dir.ts
3182
- import { readFileSync, readdirSync } from "fs";
3183
- import * as path from "path";
3184
3178
  function readPackFile(file) {
3185
3179
  try {
3186
3180
  const parsed = JSON.parse(readFileSync(file, "utf8"));
@@ -3190,21 +3184,22 @@ function readPackFile(file) {
3190
3184
  }
3191
3185
  }
3192
3186
  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
+ };
3193
3200
  return {
3194
3201
  id,
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
- },
3202
+ resolve,
3208
3203
  list() {
3209
3204
  let names;
3210
3205
  try {
@@ -3213,16 +3208,14 @@ function createDirPackSource(id, dir) {
3213
3208
  return [];
3214
3209
  }
3215
3210
  const out = [];
3216
- for (const file of names) {
3217
- const pack = this.resolve(file.slice(0, -5));
3211
+ for (const f of names) {
3212
+ const pack = resolve(f.slice(0, -5));
3218
3213
  if (pack) out.push(pack);
3219
3214
  }
3220
3215
  return out;
3221
3216
  }
3222
3217
  };
3223
3218
  }
3224
-
3225
- // src/packs/resolver.ts
3226
3219
  function createPackResolver(sources) {
3227
3220
  return {
3228
3221
  sources,
@@ -3249,13 +3242,9 @@ function createPackResolver(sources) {
3249
3242
  }
3250
3243
  };
3251
3244
  }
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));
3245
+ function defaultPackSources(opts) {
3246
+ const sources = [createDirPackSource("project", opts.projectDir)];
3247
+ for (const dir of opts.userDirs ?? []) sources.push(createDirPackSource("user", dir));
3259
3248
  sources.push(builtinSource);
3260
3249
  return sources;
3261
3250
  }