afucontext 0.1.21 → 0.1.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "afucontext",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Local asynchronous context compression and diagnostics",
package/release.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "0.1.21",
2
+ "version": "0.1.22",
3
3
  "name": "afucontext",
4
- "build": "ac2723431caf1b88720c948ddd41fd3cf9e4f5079e6c4bb5af426bc52693d59c",
5
- "wheel": "afu_context_local-0.1.21-py3-none-any.whl",
4
+ "build": "bd62776fad01e4ad0a5d43748ab9baebc426d1589e6dee4116ca4c1d3c2a3ce1",
5
+ "wheel": "afu_context_local-0.1.22-py3-none-any.whl",
6
6
  "prebuilt": false
7
7
  }
@@ -1,7 +1,7 @@
1
1
  /** Compose a disposable overlay using DSH's own YAML and patch semantics. */
2
2
  import {readFileSync, writeFileSync, realpathSync, existsSync} from 'node:fs';
3
3
  import {createRequire} from 'node:module';
4
- import {join,isAbsolute,dirname} from 'node:path';
4
+ import {join,isAbsolute,dirname,basename} from 'node:path';
5
5
  import {pathToFileURL} from 'node:url';
6
6
  import {load,dump} from 'js-yaml';
7
7
  import {entryListSchema,applyEntryPatches} from '@deepseek-ai/cordis-plugin-include';
@@ -78,18 +78,28 @@ if(process.argv[1] && import.meta.url===pathToFileURL(process.argv[1]).href) {
78
78
  try {
79
79
  const tree=load(readFileSync(0,'utf8'),{schema:entryListSchema});
80
80
  let presetModule;
81
+ let module=process.argv[2];
81
82
  if (process.argv[3] && process.argv[4]) {
82
83
  const requireHost=createRequire(realpathSync(process.argv[4]));
84
+ // Extend the compaction engine the running DSH ships, as the installed
85
+ // bundle does (host-autoload): the session format belongs to the host
86
+ // release (0.2 rejects commits built by the 0.1 engine AFU bundles).
87
+ // The shim publishes the host's modules before importing the adapter.
88
+ // An installed bundle passes its own provider.mjs, which already does.
89
+ if (basename(process.argv[2]) !== 'provider.mjs') {
90
+ module=join(process.argv[3],'provider.mjs');
91
+ writeFileSync(module, `import {createRequire} from 'node:module';\nimport {pathToFileURL} from 'node:url';\ntry {\n const host=createRequire(${JSON.stringify(realpathSync(process.argv[4]))});\n const load=name=>import(pathToFileURL(host.resolve(name)).href);\n const [basic,llm]=await Promise.all([load('@deepseek-ai/dsh-compaction-basic'),load('@deepseek-ai/dsh-llm')]);\n globalThis.__afuDshHost={BasicCompactionEngine:basic.BasicCompactionEngine,BlockAssembler:llm.BlockAssembler,createUserMessage:llm.createUserMessage};\n} catch {}\nexport default (await import(${JSON.stringify(pathToFileURL(process.argv[2]).href)})).default;\n`, {mode:0o600});
92
+ }
83
93
  try {
84
94
  const native=requireHost.resolve('@deepseek-ai/dsh-agent-presets');
85
95
  presetModule=join(process.argv[3],'presets.mjs');
86
- writeFileSync(presetModule, `import Native from ${JSON.stringify(pathToFileURL(native).href)};\nimport {presetAdapter} from ${JSON.stringify(new URL('./dsh-presets.mjs',import.meta.url).href)};\nexport default presetAdapter(Native, ${JSON.stringify(moduleReference(process.argv[2]))}, ${JSON.stringify(process.argv[3])});\n`, {mode:0o600});
96
+ writeFileSync(presetModule, `import Native from ${JSON.stringify(pathToFileURL(native).href)};\nimport {presetAdapter} from ${JSON.stringify(new URL('./dsh-presets.mjs',import.meta.url).href)};\nexport default presetAdapter(Native, ${JSON.stringify(moduleReference(module))}, ${JSON.stringify(process.argv[3])});\n`, {mode:0o600});
87
97
  } catch (error) { if(error.code!=='MODULE_NOT_FOUND') throw error; }
88
98
  }
89
99
  // The commands module sits beside the provider module: commands.mjs in an
90
100
  // installed bundle (host-autoload), commands.js in a source checkout.
91
101
  const commands=process.argv[2] ? moduleReference(['commands.mjs','commands.js'].map(n=>join(dirname(process.argv[2]),n)).find(p=>existsSync(p)) ?? join(dirname(process.argv[2]),'commands.mjs')) : undefined;
92
- const patches=overlay(tree,moduleReference(process.argv[2]),presetModule && moduleReference(presetModule),commands);
102
+ const patches=overlay(tree,moduleReference(module),presetModule && moduleReference(presetModule),commands);
93
103
  if (process.argv[5]==='web-compat') {
94
104
  const picker=tree.find(row=>!row.disabled && row.name==='@deepseek-ai/dsh-host-directory-picker-auto');
95
105
  if (picker) {