@avantf/dsh-plugin-base 0.3.1
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/LICENSE +21 -0
- package/README.md +303 -0
- package/dist/artifact.d.ts +29 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +60 -0
- package/dist/artifact.js.map +1 -0
- package/dist/bootstrap.d.ts +54 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +334 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +37 -0
- package/dist/cli.js.map +1 -0
- package/dist/compat.d.ts +413 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +742 -0
- package/dist/compat.js.map +1 -0
- package/dist/conformance.d.ts +55 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +702 -0
- package/dist/conformance.js.map +1 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/fs.d.ts +18 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +152 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/integrity.d.ts +5 -0
- package/dist/integrity.d.ts.map +1 -0
- package/dist/integrity.js +33 -0
- package/dist/integrity.js.map +1 -0
- package/dist/interface.d.ts +262 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/interface.js +136 -0
- package/dist/interface.js.map +1 -0
- package/dist/interface_gate.d.ts +61 -0
- package/dist/interface_gate.d.ts.map +1 -0
- package/dist/interface_gate.js +103 -0
- package/dist/interface_gate.js.map +1 -0
- package/dist/internal.d.ts +23 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +18 -0
- package/dist/internal.js.map +1 -0
- package/dist/kit/family.d.ts +52 -0
- package/dist/kit/family.d.ts.map +1 -0
- package/dist/kit/family.js +65 -0
- package/dist/kit/family.js.map +1 -0
- package/dist/kit/index.d.ts +26 -0
- package/dist/kit/index.d.ts.map +1 -0
- package/dist/kit/index.js +26 -0
- package/dist/kit/index.js.map +1 -0
- package/dist/kit/logger.d.ts +41 -0
- package/dist/kit/logger.d.ts.map +1 -0
- package/dist/kit/logger.js +42 -0
- package/dist/kit/logger.js.map +1 -0
- package/dist/kit/prompt_files.d.ts +90 -0
- package/dist/kit/prompt_files.d.ts.map +1 -0
- package/dist/kit/prompt_files.js +121 -0
- package/dist/kit/prompt_files.js.map +1 -0
- package/dist/kit/typert.d.ts +40 -0
- package/dist/kit/typert.d.ts.map +1 -0
- package/dist/kit/typert.js +17 -0
- package/dist/kit/typert.js.map +1 -0
- package/dist/layout.d.ts +28 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +84 -0
- package/dist/layout.js.map +1 -0
- package/dist/lint.d.ts +33 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +271 -0
- package/dist/lint.js.map +1 -0
- package/dist/lock.d.ts +12 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +93 -0
- package/dist/lock.js.map +1 -0
- package/dist/manifest.d.ts +12 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +75 -0
- package/dist/manifest.js.map +1 -0
- package/dist/net.d.ts +23 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.js +112 -0
- package/dist/net.js.map +1 -0
- package/dist/package-name.d.ts +3 -0
- package/dist/package-name.d.ts.map +1 -0
- package/dist/package-name.js +13 -0
- package/dist/package-name.js.map +1 -0
- package/dist/preset.d.ts +46 -0
- package/dist/preset.d.ts.map +1 -0
- package/dist/preset.js +230 -0
- package/dist/preset.js.map +1 -0
- package/dist/providers/archive.d.ts +32 -0
- package/dist/providers/archive.d.ts.map +1 -0
- package/dist/providers/archive.js +248 -0
- package/dist/providers/archive.js.map +1 -0
- package/dist/providers/model.d.ts +25 -0
- package/dist/providers/model.d.ts.map +1 -0
- package/dist/providers/model.js +550 -0
- package/dist/providers/model.js.map +1 -0
- package/dist/providers/npm.d.ts +21 -0
- package/dist/providers/npm.d.ts.map +1 -0
- package/dist/providers/npm.js +458 -0
- package/dist/providers/npm.js.map +1 -0
- package/dist/provisioner.d.ts +21 -0
- package/dist/provisioner.d.ts.map +1 -0
- package/dist/provisioner.js +962 -0
- package/dist/provisioner.js.map +1 -0
- package/dist/semver.d.ts +31 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +244 -0
- package/dist/semver.js.map +1 -0
- package/dist/state.d.ts +71 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +225 -0
- package/dist/state.js.map +1 -0
- package/dist/tar.d.ts +10 -0
- package/dist/tar.d.ts.map +1 -0
- package/dist/tar.js +178 -0
- package/dist/tar.js.map +1 -0
- package/dist/types.d.ts +431 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/zip.d.ts +8 -0
- package/dist/zip.d.ts.map +1 -0
- package/dist/zip.js +109 -0
- package/dist/zip.js.map +1 -0
- package/package.json +84 -0
package/dist/internal.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework building blocks shared by the core and the entry points.
|
|
3
|
+
* @module internal
|
|
4
|
+
*/
|
|
5
|
+
export { defaultFs, exists, linkOrCopy } from './fs.js';
|
|
6
|
+
export { defaultLock, pidIsAlive } from './lock.js';
|
|
7
|
+
export { extractTarGz, safeEntryPath } from './tar.js';
|
|
8
|
+
export { extractZip } from './zip.js';
|
|
9
|
+
export { assertRange, compareVersions, parseRange, parseVersion, satisfies, satisfiesRange, selectVersion } from './semver.js';
|
|
10
|
+
export { INSTALL_MANIFEST_FILE, MANIFEST_SCHEMA_VERSION, aliasLegacyManifest, decodeJson, encodeInstallManifest, readInstallManifest, } from './manifest.js';
|
|
11
|
+
export { assertPackageName } from './package-name.js';
|
|
12
|
+
export { sriOfSha256, verifyIntegrity } from './integrity.js';
|
|
13
|
+
export { LAYOUT_SCHEMA_VERSION, STATUS_SCHEMA_VERSION, mergeRows, persistStatus, readDeclared, readLayout, readStatus, recordDeclared, writeLayout, } from './state.js';
|
|
14
|
+
export { BUILTIN_KINDS, IMPLEMENTED_POLICY_KEYS, ITEM_FIELDS, MANIFEST_FIELDS, UNIMPLEMENTED_POLICY_KEYS, UNIMPLEMENTED_PROVISION_POLICY_KEYS, hasStarBranch, isNamespacedKind, lintManifest, lintManifestText, unknownFields, } from './lint.js';
|
|
15
|
+
export { candidateUrls, downloadBytes, fetchImplOf, platformKey, readCapped, signalFor, verifySha256, DEFAULT_MAX_BYTES } from './net.js';
|
|
16
|
+
export { CONTROL_DIR, assertSafeRelativePath, assertSafeRelativeRoot, controlRoot, declaredPath, layoutPath, lockPath, quarantineRoot, stagingDir, statusLockPath, statusPath, tempRoot, versionSegment, } from './layout.js';
|
|
17
|
+
export { BOOTSTRAP_SUBPATH, FRAMEWORK_INLINING_BEACONS, FRAMEWORK_PACKAGE, MIN_INLINING_BEACONS, findFrameworkImports, findInliningBeacons, isBootstrapSpecifier, } from './artifact.js';
|
|
18
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE9H,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACV,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,cAAc,EACd,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,yBAAyB,EACzB,mCAAmC,EACnC,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,aAAa,GACd,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACzI,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACV,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** `~/x` → `<home>/x`, `~` → `<home>`; anything else is used as given. */
|
|
2
|
+
export declare function expandHome(path: string, home?: string): string;
|
|
3
|
+
/** The family root: `$AVANTF_HOME` when set, else `~/.avantf/env`. */
|
|
4
|
+
export declare function familyHome(env?: Record<string, string | undefined>): string;
|
|
5
|
+
/** The managed external-binary root (`<family root>/tools`). */
|
|
6
|
+
export declare function familyToolsDir(env?: Record<string, string | undefined>): string;
|
|
7
|
+
/** The managed model-cache root (`<family root>/models`). */
|
|
8
|
+
export declare function familyModelsDir(env?: Record<string, string | undefined>): string;
|
|
9
|
+
/**
|
|
10
|
+
* The input to {@link resolveDataHome}: every value in a NAMED slot, never a position.
|
|
11
|
+
*
|
|
12
|
+
* The slots are the family's layers, and their meanings ARE the contract:
|
|
13
|
+
*
|
|
14
|
+
* - `explicit` — layer ⑤, a caller's own value (the CLI's `--data-home`);
|
|
15
|
+
* - `env` — layer ④, the environment map `$AVANTF_HOME` is read from; defaults to `process.env`;
|
|
16
|
+
* - `configured` — layer ②, the resolved `common.dataHome` from configuration.
|
|
17
|
+
*
|
|
18
|
+
* The named shape is not decoration. Both implementations used to take three POSITIONAL arguments and
|
|
19
|
+
* disagreed about their order (this kit read `(explicit, env, common)`, the mem engine
|
|
20
|
+
* `(common, explicit)`), so "which slot does the profile's `dataHome` belong in?" — the one question
|
|
21
|
+
* that decides where the user's memory, knowledge and prompts live — was answerable only by reading
|
|
22
|
+
* the call site's argument order. `common.dataHome` carries a schema default and therefore ALWAYS
|
|
23
|
+
* holds a value: in the `explicit` slot it promotes layer ② above layer ④ and silently kills
|
|
24
|
+
* `$AVANTF_HOME` on that side of the family, which is how the same config came to resolve to two
|
|
25
|
+
* different directories. A named object makes that a type error instead of a diff nobody reads.
|
|
26
|
+
*
|
|
27
|
+
* This shape is the base interface type's `dataHomeInput` member; the two must stay identical.
|
|
28
|
+
*/
|
|
29
|
+
export interface DataHomeInput {
|
|
30
|
+
/** Layer ⑤: an explicit caller value; blank or omitted means "not given". */
|
|
31
|
+
readonly explicit?: string;
|
|
32
|
+
/** Layer ④: the environment map; defaults to `process.env`. */
|
|
33
|
+
readonly env?: Record<string, string | undefined>;
|
|
34
|
+
/** Layer ②: the configured `common.dataHome`; blank or omitted means "not configured". */
|
|
35
|
+
readonly configured?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The data root: an explicit caller value (⑤) → `$AVANTF_HOME` (④) → the configured
|
|
39
|
+
* `common.dataHome` (②) → `~/.avantf`. That is the family's layer order (`mem/AGENTS.md`
|
|
40
|
+
* 「配置分层」: built-in → common.yaml → store → ENV → explicit), so the environment wins over the
|
|
41
|
+
* config file and an explicit argument wins over both.
|
|
42
|
+
*
|
|
43
|
+
* The configured value is a NAMED slot ({@link DataHomeInput}) for the reason recorded there: it
|
|
44
|
+
* always holds a value, so a positional API let a caller hand it to the `explicit` slot and make
|
|
45
|
+
* `$AVANTF_HOME` dead on one side of the family. The two implementations (this kit and
|
|
46
|
+
* `@avantf/mem-contract`) are pinned to the same answer by
|
|
47
|
+
* `mem/packages/plugin/test/family_pin.spec.ts`.
|
|
48
|
+
*
|
|
49
|
+
* `~/` (and a bare `~`) is expanded here so every caller agrees on one directory.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveDataHome(input?: DataHomeInput): string;
|
|
52
|
+
//# sourceMappingURL=family.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"family.d.ts","sourceRoot":"","sources":["../../src/kit/family.ts"],"names":[],"mappings":"AAwBA,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAGzE;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAGxF;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAE5F;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAE7F;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,GAAE,aAAkB,GAAG,MAAM,CAOjE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's path conventions — ONE definition of two directories that four modules used to spell
|
|
3
|
+
* out independently (`@avantf/mem-contract`, `@avantf/mem-provision`, `@avantf/mem`'s config paths
|
|
4
|
+
* and the work plugin's prompt layer). They are part of the kit because a change to either convention
|
|
5
|
+
* must be fixable with one base release.
|
|
6
|
+
*
|
|
7
|
+
* TWO ROOTS, and they are deliberately different. Confusing them is the bug this module documents:
|
|
8
|
+
*
|
|
9
|
+
* - the **family root** (`familyHome`) is where the environment framework installs what it manages:
|
|
10
|
+
* `$AVANTF_HOME` when set, else `~/.avantf/env`. Tools live in `<family root>/tools`, model
|
|
11
|
+
* weights in `<family root>/models`.
|
|
12
|
+
* - the **data root** (`resolveDataHome`) is where a plugin keeps the user's OWN data and editable
|
|
13
|
+
* text: `memory/`, `knowledge/`, `configs/*.yaml`, `prompts/*.md`. Precedence is an explicit caller
|
|
14
|
+
* value (⑤) → `$AVANTF_HOME` (④) → the configured `dataHome` (②) → `~/.avantf`.
|
|
15
|
+
*
|
|
16
|
+
* Setting `$AVANTF_HOME` therefore redirects BOTH a deployment's data and its managed resources under
|
|
17
|
+
* one prefix — which is what a sandbox or a test needs — while the unset default keeps them apart
|
|
18
|
+
* (`~/.avantf` for data, `~/.avantf/env` for resources).
|
|
19
|
+
*
|
|
20
|
+
* @module @avantf/dsh-plugin-base/kit/family
|
|
21
|
+
*/
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
/** `~/x` → `<home>/x`, `~` → `<home>`; anything else is used as given. */
|
|
25
|
+
export function expandHome(path, home = homedir()) {
|
|
26
|
+
if (path === '~')
|
|
27
|
+
return home;
|
|
28
|
+
return path.startsWith('~/') ? join(home, path.slice(2)) : path;
|
|
29
|
+
}
|
|
30
|
+
/** The family root: `$AVANTF_HOME` when set, else `~/.avantf/env`. */
|
|
31
|
+
export function familyHome(env = process.env) {
|
|
32
|
+
const configured = env['AVANTF_HOME']?.trim() ?? '';
|
|
33
|
+
return configured !== '' ? expandHome(configured) : join(homedir(), '.avantf', 'env');
|
|
34
|
+
}
|
|
35
|
+
/** The managed external-binary root (`<family root>/tools`). */
|
|
36
|
+
export function familyToolsDir(env = process.env) {
|
|
37
|
+
return join(familyHome(env), 'tools');
|
|
38
|
+
}
|
|
39
|
+
/** The managed model-cache root (`<family root>/models`). */
|
|
40
|
+
export function familyModelsDir(env = process.env) {
|
|
41
|
+
return join(familyHome(env), 'models');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The data root: an explicit caller value (⑤) → `$AVANTF_HOME` (④) → the configured
|
|
45
|
+
* `common.dataHome` (②) → `~/.avantf`. That is the family's layer order (`mem/AGENTS.md`
|
|
46
|
+
* 「配置分层」: built-in → common.yaml → store → ENV → explicit), so the environment wins over the
|
|
47
|
+
* config file and an explicit argument wins over both.
|
|
48
|
+
*
|
|
49
|
+
* The configured value is a NAMED slot ({@link DataHomeInput}) for the reason recorded there: it
|
|
50
|
+
* always holds a value, so a positional API let a caller hand it to the `explicit` slot and make
|
|
51
|
+
* `$AVANTF_HOME` dead on one side of the family. The two implementations (this kit and
|
|
52
|
+
* `@avantf/mem-contract`) are pinned to the same answer by
|
|
53
|
+
* `mem/packages/plugin/test/family_pin.spec.ts`.
|
|
54
|
+
*
|
|
55
|
+
* `~/` (and a bare `~`) is expanded here so every caller agrees on one directory.
|
|
56
|
+
*/
|
|
57
|
+
export function resolveDataHome(input = {}) {
|
|
58
|
+
const layer5 = input.explicit?.trim() ?? '';
|
|
59
|
+
const env = input.env ?? process.env;
|
|
60
|
+
const fromEnv = env['AVANTF_HOME']?.trim() ?? '';
|
|
61
|
+
const layer2 = input.configured?.trim() ?? '';
|
|
62
|
+
const base = layer5 !== '' ? layer5 : fromEnv !== '' ? fromEnv : layer2 !== '' ? layer2 : '~/.avantf';
|
|
63
|
+
return expandHome(base);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=family.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"family.js","sourceRoot":"","sources":["../../src/kit/family.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAe,OAAO,EAAE;IAC/D,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACjE,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,UAAU,CAAC,MAA0C,OAAO,CAAC,GAAG;IAC9E,MAAM,UAAU,GAAG,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IACnD,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AACvF,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,cAAc,CAAC,MAA0C,OAAO,CAAC,GAAG;IAClF,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,eAAe,CAAC,MAA0C,OAAO,CAAC,GAAG;IACnF,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC;AA+BD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,QAAuB,EAAE;IACvD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAA;IACpC,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAChD,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC7C,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAA;IACrG,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared KIT: pure, DSH-free helpers used by the family's DSH plugins.
|
|
3
|
+
*
|
|
4
|
+
* This is NOT a package. It is a source area INSIDE the one published base package
|
|
5
|
+
* (`@avantf/dsh-plugin-base`), and that is the whole point: fixing or extending a shared helper must
|
|
6
|
+
* be possible with ONE base release, without rebuilding or republishing any plugin. Plugins
|
|
7
|
+
* therefore never inline this code — they load the base at startup through the inlined bootstrap
|
|
8
|
+
* (the only vendored piece) and take these capabilities off the loaded module at runtime:
|
|
9
|
+
*
|
|
10
|
+
* - prompt file reading/writing (`PromptFiles`),
|
|
11
|
+
* - the plugin logger (`createPluginLogger`),
|
|
12
|
+
* - the family path conventions (`familyHome` / `familyToolsDir` / `familyModelsDir` /
|
|
13
|
+
* `resolveDataHome` / `expandHome`),
|
|
14
|
+
* - the Typert wire conventions (`strictCodec` / endpoint and field symbols).
|
|
15
|
+
*
|
|
16
|
+
* When the base is unavailable, every consumer degrades instead of failing: the prompt layer falls
|
|
17
|
+
* back to the plugin's OWN built-in default bodies, the compatibility gate logs its `compat:`
|
|
18
|
+
* WARNING and is skipped, and the plugin mounts in full. See the root `AGENTS.md`.
|
|
19
|
+
*
|
|
20
|
+
* @module @avantf/dsh-plugin-base/kit
|
|
21
|
+
*/
|
|
22
|
+
export * from './prompt_files.js';
|
|
23
|
+
export * from './logger.js';
|
|
24
|
+
export * from './typert.js';
|
|
25
|
+
export * from './family.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared KIT: pure, DSH-free helpers used by the family's DSH plugins.
|
|
3
|
+
*
|
|
4
|
+
* This is NOT a package. It is a source area INSIDE the one published base package
|
|
5
|
+
* (`@avantf/dsh-plugin-base`), and that is the whole point: fixing or extending a shared helper must
|
|
6
|
+
* be possible with ONE base release, without rebuilding or republishing any plugin. Plugins
|
|
7
|
+
* therefore never inline this code — they load the base at startup through the inlined bootstrap
|
|
8
|
+
* (the only vendored piece) and take these capabilities off the loaded module at runtime:
|
|
9
|
+
*
|
|
10
|
+
* - prompt file reading/writing (`PromptFiles`),
|
|
11
|
+
* - the plugin logger (`createPluginLogger`),
|
|
12
|
+
* - the family path conventions (`familyHome` / `familyToolsDir` / `familyModelsDir` /
|
|
13
|
+
* `resolveDataHome` / `expandHome`),
|
|
14
|
+
* - the Typert wire conventions (`strictCodec` / endpoint and field symbols).
|
|
15
|
+
*
|
|
16
|
+
* When the base is unavailable, every consumer degrades instead of failing: the prompt layer falls
|
|
17
|
+
* back to the plugin's OWN built-in default bodies, the compatibility gate logs its `compat:`
|
|
18
|
+
* WARNING and is skipped, and the plugin mounts in full. See the root `AGENTS.md`.
|
|
19
|
+
*
|
|
20
|
+
* @module @avantf/dsh-plugin-base/kit
|
|
21
|
+
*/
|
|
22
|
+
export * from './prompt_files.js';
|
|
23
|
+
export * from './logger.js';
|
|
24
|
+
export * from './typert.js';
|
|
25
|
+
export * from './family.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/kit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin log sink — ONE implementation for every plugin in the family.
|
|
3
|
+
*
|
|
4
|
+
* It merges the two loggers the plugins used to carry separately:
|
|
5
|
+
*
|
|
6
|
+
* - the memory side's `createConsoleLogger(prefix)` (`@avantf/mem-contract`): a stable
|
|
7
|
+
* `[avantf-mem] LEVEL message` line on STDERR, because the CLI and the MCP server own stdout for
|
|
8
|
+
* JSON / JSON-RPC;
|
|
9
|
+
* - the work side's `createLogger(host, sink)`: the same stderr line, PLUS a mirror into the host's
|
|
10
|
+
* `ctx.logger` (`ctx.logger` alone never reaches the terminal).
|
|
11
|
+
*
|
|
12
|
+
* Both planes are kept, and each is independently injectable so a spec can assert the lines. Nothing
|
|
13
|
+
* here throws: a logging failure must never take down the engine it is describing, so the host
|
|
14
|
+
* mirror is wrapped and the sink is the caller's responsibility.
|
|
15
|
+
*
|
|
16
|
+
* @module @avantf/dsh-plugin-base/kit/logger
|
|
17
|
+
*/
|
|
18
|
+
/** One leveled log sink. */
|
|
19
|
+
export interface PluginLogger {
|
|
20
|
+
info(message: string): void;
|
|
21
|
+
warn(message: string): void;
|
|
22
|
+
error(message: string): void;
|
|
23
|
+
}
|
|
24
|
+
/** The `ctx.logger` slice a plugin mirrors into; every method is optional. */
|
|
25
|
+
export type PluginLoggerHost = Partial<PluginLogger>;
|
|
26
|
+
export interface PluginLoggerOptions {
|
|
27
|
+
/** The stable token every line starts with, e.g. `[avantf-mem]`. */
|
|
28
|
+
readonly prefix: string;
|
|
29
|
+
/** The host logger to mirror into, when there is one. */
|
|
30
|
+
readonly host?: PluginLoggerHost;
|
|
31
|
+
/** Where the stderr line lands; defaults to `console.error` (stdout stays free). */
|
|
32
|
+
readonly sink?: (line: string) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a plugin logger.
|
|
36
|
+
*
|
|
37
|
+
* @param options - the prefix, an optional host mirror, an optional sink override.
|
|
38
|
+
* @returns the leveled logger.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createPluginLogger(options: PluginLoggerOptions): PluginLogger;
|
|
41
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/kit/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,4BAA4B;AAC5B,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAEpD,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAA;IAChC,oFAAoF;IACpF,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAgB7E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin log sink — ONE implementation for every plugin in the family.
|
|
3
|
+
*
|
|
4
|
+
* It merges the two loggers the plugins used to carry separately:
|
|
5
|
+
*
|
|
6
|
+
* - the memory side's `createConsoleLogger(prefix)` (`@avantf/mem-contract`): a stable
|
|
7
|
+
* `[avantf-mem] LEVEL message` line on STDERR, because the CLI and the MCP server own stdout for
|
|
8
|
+
* JSON / JSON-RPC;
|
|
9
|
+
* - the work side's `createLogger(host, sink)`: the same stderr line, PLUS a mirror into the host's
|
|
10
|
+
* `ctx.logger` (`ctx.logger` alone never reaches the terminal).
|
|
11
|
+
*
|
|
12
|
+
* Both planes are kept, and each is independently injectable so a spec can assert the lines. Nothing
|
|
13
|
+
* here throws: a logging failure must never take down the engine it is describing, so the host
|
|
14
|
+
* mirror is wrapped and the sink is the caller's responsibility.
|
|
15
|
+
*
|
|
16
|
+
* @module @avantf/dsh-plugin-base/kit/logger
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Build a plugin logger.
|
|
20
|
+
*
|
|
21
|
+
* @param options - the prefix, an optional host mirror, an optional sink override.
|
|
22
|
+
* @returns the leveled logger.
|
|
23
|
+
*/
|
|
24
|
+
export function createPluginLogger(options) {
|
|
25
|
+
const { prefix, host } = options;
|
|
26
|
+
const sink = options.sink ?? ((line) => { console.error(line); });
|
|
27
|
+
const emit = (level, message) => {
|
|
28
|
+
sink(`${prefix} ${level.toUpperCase()} ${message}`);
|
|
29
|
+
try {
|
|
30
|
+
host?.[level]?.(`${prefix} ${message}`);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// A logging failure must never take down the engine it is describing.
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
info: (message) => { emit('info', message); },
|
|
38
|
+
warn: (message) => { emit('warn', message); },
|
|
39
|
+
error: (message) => { emit('error', message); },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/kit/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAqBH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,IAAY,EAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAC9E,MAAM,IAAI,GAAG,CAAC,KAAgC,EAAE,OAAe,EAAQ,EAAE;QACvE,IAAI,CAAC,GAAG,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,OAAO,EAAE,CAAC,CAAA;QACnD,IAAI,CAAC;YACH,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC,CAAA;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;QACxE,CAAC;IACH,CAAC,CAAA;IACD,OAAO;QACL,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA,CAAC,CAAC;QAC5C,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA,CAAC,CAAC;QAC5C,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA,CAAC,CAAC;KAC/C,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-editable prompt text: one `.md` per prompt section, in the family's shared prompt directory
|
|
3
|
+
* (`<data home>/prompts`, where each plugin owns a prefix — `mem-*` in the memory plugin, `work-*`
|
|
4
|
+
* in the work engine).
|
|
5
|
+
*
|
|
6
|
+
* This lived, byte-for-byte identical except for its header comment, in BOTH plugins
|
|
7
|
+
* (`@avantf/dsh-mem`'s and `@avantf/dsh-work`'s `packages/plugin/src/prompt_files.ts`) — the copy
|
|
8
|
+
* was deliberate while the two were separate repositories with no shared family package, and the two
|
|
9
|
+
* headers said "if a third consumer appears, hoist it into one shared package rather than copy it
|
|
10
|
+
* again". The merge into one workspace is that moment: it now lives in the base
|
|
11
|
+
* (`@avantf/dsh-plugin-base/kit`), and a plugin takes it off the base module at RUNTIME, loaded by
|
|
12
|
+
* the inlined bootstrap. It is deliberately NOT inlined into a plugin bundle: a fix to the shared
|
|
13
|
+
* prompt layer must ship as ONE base release, with no rebuild or republish of any plugin. When the
|
|
14
|
+
* base is absent, the plugin degrades instead of failing — the prompt layer is unavailable and the
|
|
15
|
+
* plugin uses its OWN built-in default bodies (the defaults are the plugin's content, not a copy of
|
|
16
|
+
* this module).
|
|
17
|
+
*
|
|
18
|
+
* Every prompt section a plugin contributes has the SAME lifecycle — the file has to exist, a
|
|
19
|
+
* missing or blank one is filled with the built-in default, and what is on disk wins on the next
|
|
20
|
+
* start — so that flow lives here ONCE instead of once per section next to each default string. The
|
|
21
|
+
* caller owns the manifest (file name, which section it feeds, the default body); this owns HOW the
|
|
22
|
+
* file is materialized and read, the same division of labour `GitRepo` (in the engine) uses for the
|
|
23
|
+
* on-disk artifacts it versions without knowing what they are.
|
|
24
|
+
*
|
|
25
|
+
* THREE PROPERTIES ARE LOAD-BEARING, and they are why this is not `readFileSync` at each call site:
|
|
26
|
+
*
|
|
27
|
+
* - **It never throws.** A read-only data home, a directory sitting where a file should be, a
|
|
28
|
+
* permission error — none of them may keep a plugin from mounting, because a throwing `apply`
|
|
29
|
+
* fails the whole `dsh web` boot (measured). Every failure warns and falls back to the default
|
|
30
|
+
* text, the same rule `IngestResult.file_error` follows for the managed document copy.
|
|
31
|
+
* - **It never overwrites what the user wrote.** Only a missing file or a blank one is written; one
|
|
32
|
+
* visible character makes the file the user's, including a wrong one.
|
|
33
|
+
* - **The file IS the prompt.** Its whole body is injected (outer whitespace trimmed, BOM stripped,
|
|
34
|
+
* CRLF normalized). There is no frontmatter, no marker and no header comment to strip — a comment
|
|
35
|
+
* would be injected into the model's prompt too, so the default files carry none, and the
|
|
36
|
+
* documentation for them lives in DESIGN and the README.
|
|
37
|
+
*/
|
|
38
|
+
export interface PromptFileSpec {
|
|
39
|
+
/** File name inside the prompt directory; it is also the handle used in log lines. */
|
|
40
|
+
readonly file: string;
|
|
41
|
+
/** Written when the file is missing or blank; also the text used when the disk is unusable. */
|
|
42
|
+
readonly fallback: string;
|
|
43
|
+
}
|
|
44
|
+
export interface LoadedPromptText {
|
|
45
|
+
readonly file: string;
|
|
46
|
+
readonly path: string;
|
|
47
|
+
/** The text to inject: the file's body, or the fallback when the file could not be used. */
|
|
48
|
+
readonly text: string;
|
|
49
|
+
/**
|
|
50
|
+
* `file` — read from disk and used as-is.
|
|
51
|
+
* `default` — the default was used, either because it was just written (missing/blank) or because
|
|
52
|
+
* the file could not be read/created. `wrote` says which.
|
|
53
|
+
*/
|
|
54
|
+
readonly source: 'file' | 'default';
|
|
55
|
+
/** True when this call created or filled the file. */
|
|
56
|
+
readonly wrote: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** The filesystem slice this module uses; injectable so its specs need no real directory. */
|
|
59
|
+
export interface PromptFilesIo {
|
|
60
|
+
exists(path: string): boolean;
|
|
61
|
+
read(path: string): string;
|
|
62
|
+
/** Must land atomically (temp file + rename), so a crash cannot leave a half-written prompt. */
|
|
63
|
+
write(path: string, text: string): void;
|
|
64
|
+
ensureDir(path: string): void;
|
|
65
|
+
}
|
|
66
|
+
/** Structurally what a plugin logger already is; declared locally to keep this module dependency-free. */
|
|
67
|
+
export interface PromptFilesLogger {
|
|
68
|
+
info(message: string): void;
|
|
69
|
+
warn(message: string): void;
|
|
70
|
+
}
|
|
71
|
+
export interface PromptFilesOptions {
|
|
72
|
+
/** Directory holding one `.md` per section. Created when missing. */
|
|
73
|
+
readonly dir: string;
|
|
74
|
+
readonly logger?: PromptFilesLogger;
|
|
75
|
+
/** Overridable for tests; defaults to the real filesystem. */
|
|
76
|
+
readonly io?: PromptFilesIo;
|
|
77
|
+
}
|
|
78
|
+
export declare class PromptFiles {
|
|
79
|
+
readonly dir: string;
|
|
80
|
+
private readonly logger;
|
|
81
|
+
private readonly io;
|
|
82
|
+
constructor(options: PromptFilesOptions);
|
|
83
|
+
/**
|
|
84
|
+
* Ensure every spec's file exists with content, then return the text to inject. Ordered like the
|
|
85
|
+
* manifest, so the caller can zip the result back onto its sections.
|
|
86
|
+
*/
|
|
87
|
+
load(specs: readonly PromptFileSpec[]): readonly LoadedPromptText[];
|
|
88
|
+
private loadOne;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=prompt_files.d.ts.map
|
|
@@ -0,0 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CAAC,EAAE,CAAC,EAAE,aAAa,CAAA;CAC5B;AA6DD,qBAAa,WAAW;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAe;gBAEtB,OAAO,EAAE,kBAAkB;IAMvC;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,gBAAgB,EAAE;IAkBnE,OAAO,CAAC,OAAO;CAwBhB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
/** The temp files {@link nodeIo.write} leaves beside a prompt file, and the age past which one
|
|
4
|
+
* certainly belongs to a writer that will never rename it. Same discipline as the provisioner's
|
|
5
|
+
* `fs.ts`, which sweeps `.atomic-*` the same way. */
|
|
6
|
+
const TEMP_SUFFIX = /\.tmp-\d+$/;
|
|
7
|
+
const STALE_TEMP_MS = 5 * 60_000;
|
|
8
|
+
/** Best-effort removal of dead sibling temps, so a crash never leaves litter in the user's own
|
|
9
|
+
* `prompts/` directory — that directory is theirs (hand-edited files live in it), not ours. */
|
|
10
|
+
function sweepStaleTemps(dir, keep) {
|
|
11
|
+
let entries;
|
|
12
|
+
try {
|
|
13
|
+
entries = readdirSync(dir);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
if (!TEMP_SUFFIX.test(entry))
|
|
21
|
+
continue;
|
|
22
|
+
const candidate = join(dir, entry);
|
|
23
|
+
if (candidate === keep)
|
|
24
|
+
continue;
|
|
25
|
+
try {
|
|
26
|
+
if (now - statSync(candidate).mtimeMs > STALE_TEMP_MS)
|
|
27
|
+
rmSync(candidate, { force: true });
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// A temp that vanished under us is already gone.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const nodeIo = {
|
|
35
|
+
exists: (path) => existsSync(path),
|
|
36
|
+
read: (path) => readFileSync(path, 'utf8'),
|
|
37
|
+
write: (path, text) => {
|
|
38
|
+
const tmp = `${path}.tmp-${String(process.pid)}`;
|
|
39
|
+
// Write-then-rename so a reader never sees a half-written prompt. A crash in between used to
|
|
40
|
+
// leave `.tmp-<pid>` behind FOREVER: sweep the dead ones first, and drop this one if the rename
|
|
41
|
+
// is the step that fails (a directory sitting where the file belongs is the everyday case).
|
|
42
|
+
sweepStaleTemps(dirname(path), tmp);
|
|
43
|
+
try {
|
|
44
|
+
writeFileSync(tmp, text, 'utf8');
|
|
45
|
+
renameSync(tmp, path);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
rmSync(tmp, { force: true });
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
ensureDir: (path) => {
|
|
53
|
+
mkdirSync(path, { recursive: true });
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
/** BOM off, CRLF in, outer whitespace off: what the file means, not what the editor left behind. */
|
|
57
|
+
function normalize(text) {
|
|
58
|
+
return text.replace(/^\uFEFF/, '').replace(/\r\n?/gu, '\n').trim();
|
|
59
|
+
}
|
|
60
|
+
function reason(error) {
|
|
61
|
+
return error instanceof Error ? error.message : String(error);
|
|
62
|
+
}
|
|
63
|
+
export class PromptFiles {
|
|
64
|
+
dir;
|
|
65
|
+
logger;
|
|
66
|
+
io;
|
|
67
|
+
constructor(options) {
|
|
68
|
+
this.dir = options.dir;
|
|
69
|
+
this.logger = options.logger;
|
|
70
|
+
this.io = options.io ?? nodeIo;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Ensure every spec's file exists with content, then return the text to inject. Ordered like the
|
|
74
|
+
* manifest, so the caller can zip the result back onto its sections.
|
|
75
|
+
*/
|
|
76
|
+
load(specs) {
|
|
77
|
+
const fallbackOf = (spec) => ({
|
|
78
|
+
file: spec.file,
|
|
79
|
+
path: join(this.dir, spec.file),
|
|
80
|
+
text: normalize(spec.fallback),
|
|
81
|
+
source: 'default',
|
|
82
|
+
wrote: false,
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
this.io.ensureDir(this.dir);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// One warning for the directory, not one per file: the cause is the same for all of them.
|
|
89
|
+
this.logger?.warn(`prompt directory ${this.dir} is unusable (${reason(error)}); using the built-in prompts`);
|
|
90
|
+
return specs.map(fallbackOf);
|
|
91
|
+
}
|
|
92
|
+
return specs.map((spec) => this.loadOne(spec));
|
|
93
|
+
}
|
|
94
|
+
loadOne(spec) {
|
|
95
|
+
const path = join(this.dir, spec.file);
|
|
96
|
+
const fallback = normalize(spec.fallback);
|
|
97
|
+
const failed = (error) => {
|
|
98
|
+
this.logger?.warn(`prompt file ${path} is unusable (${reason(error)}); using the built-in default`);
|
|
99
|
+
return { file: spec.file, path, text: fallback, source: 'default', wrote: false };
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
if (this.io.exists(path)) {
|
|
103
|
+
const text = normalize(this.io.read(path));
|
|
104
|
+
// A file the user edited is used verbatim — including one we would word differently.
|
|
105
|
+
if (text !== '')
|
|
106
|
+
return { file: spec.file, path, text, source: 'file', wrote: false };
|
|
107
|
+
// Blank is not an edit, it is an unfinished one: fill it (the caller's own rule).
|
|
108
|
+
this.io.write(path, `${fallback}\n`);
|
|
109
|
+
this.logger?.info(`prompt file was blank and has been filled: ${path}`);
|
|
110
|
+
return { file: spec.file, path, text: fallback, source: 'default', wrote: true };
|
|
111
|
+
}
|
|
112
|
+
this.io.write(path, `${fallback}\n`);
|
|
113
|
+
this.logger?.info(`prompt file created: ${path}`);
|
|
114
|
+
return { file: spec.file, path, text: fallback, source: 'default', wrote: true };
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return failed(error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=prompt_files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt_files.js","sourceRoot":"","sources":["../../src/kit/prompt_files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAoFzC;;sDAEsD;AACtD,MAAM,WAAW,GAAG,YAAY,CAAA;AAChC,MAAM,aAAa,GAAG,CAAC,GAAG,MAAM,CAAA;AAEhC;gGACgG;AAChG,SAAS,eAAe,CAAC,GAAW,EAAE,IAAY;IAChD,IAAI,OAA0B,CAAA;IAC9B,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAM;IACR,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACtB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,SAAQ;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAClC,IAAI,SAAS,KAAK,IAAI;YAAE,SAAQ;QAChC,IAAI,CAAC;YACH,IAAI,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,GAAG,aAAa;gBAAE,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3F,CAAC;Q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EAAE,CAAC,CAAA;YACjD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typert wire conventions shared by the family's plugins.
|
|
3
|
+
*
|
|
4
|
+
* A DSH plugin's Remote face is hand-written here (the Typert generator runs only inside the harness
|
|
5
|
+
* workspace), and both plugins independently arrived at the same conventions. The GENERATOR-level
|
|
6
|
+
* parts live here once; the descriptor assembly stays per plugin because the two really differ (the
|
|
7
|
+
* work engine adds `stream`/cancellation methods, the memory plugin has a `parameter()` helper with
|
|
8
|
+
* `acceptsUndefined`). Only the genuinely identical part is hoisted — a fake abstraction with a bag
|
|
9
|
+
* of switches would be worse than the duplication it removes.
|
|
10
|
+
*
|
|
11
|
+
* The type-symbol convention is `<package>#<namespace>/<method>:<field>`; the probe, the runtime
|
|
12
|
+
* registry and the report all key off it, so it must not drift between the two plugins.
|
|
13
|
+
*
|
|
14
|
+
* @module @avantf/dsh-plugin-base/kit/typert
|
|
15
|
+
*/
|
|
16
|
+
import type { ZodType } from 'zod';
|
|
17
|
+
/**
|
|
18
|
+
* One `strict` codec: the schema plus the symbol the generator would name.
|
|
19
|
+
*
|
|
20
|
+
* Carries BOTH members on purpose. The host's validator moved from `codec.schema.parse` (dsh 0.1.5)
|
|
21
|
+
* to `codec.create()` (0.1.6), and each generation checks only its own — so a codec missing one of
|
|
22
|
+
* them makes a healthy host read as an incompatible one, and the failure shows up as a REFUSED mount
|
|
23
|
+
* rather than as a missing neighbour. Measured on the memory plugin first; the work copy had drifted
|
|
24
|
+
* to the one-member shape and was fixed to match. Do not "simplify" this back.
|
|
25
|
+
*/
|
|
26
|
+
export interface StrictCodec {
|
|
27
|
+
readonly mode: 'strict';
|
|
28
|
+
readonly typeSymbol: string;
|
|
29
|
+
readonly schema: ZodType;
|
|
30
|
+
readonly create: () => ZodType;
|
|
31
|
+
}
|
|
32
|
+
/** Build one strict codec; `typeSymbol` is the `<package>#<namespace>/<method>:<field>` name. */
|
|
33
|
+
export declare function strictCodec(schema: ZodType, typeSymbol: string): StrictCodec;
|
|
34
|
+
/** The invocation id of one method: `<package>#<namespace>/<method>`. */
|
|
35
|
+
export declare function endpointId(pkg: string, namespace: string, method: string): string;
|
|
36
|
+
/** The type symbol of one field of one method. */
|
|
37
|
+
export declare function fieldSymbol(pkg: string, namespace: string, method: string, field: string): string;
|
|
38
|
+
/** The type symbol of a method's result. */
|
|
39
|
+
export declare function resultSymbol(pkg: string, namespace: string, method: string): string;
|
|
40
|
+
//# sourceMappingURL=typert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typert.d.ts","sourceRoot":"","sources":["../../src/kit/typert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAElC;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAA;CAC/B;AAED,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,CAE5E;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjG;AAED,4CAA4C;AAC5C,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Build one strict codec; `typeSymbol` is the `<package>#<namespace>/<method>:<field>` name. */
|
|
2
|
+
export function strictCodec(schema, typeSymbol) {
|
|
3
|
+
return { mode: 'strict', typeSymbol, schema, create: () => schema };
|
|
4
|
+
}
|
|
5
|
+
/** The invocation id of one method: `<package>#<namespace>/<method>`. */
|
|
6
|
+
export function endpointId(pkg, namespace, method) {
|
|
7
|
+
return `${pkg}#${namespace}/${method}`;
|
|
8
|
+
}
|
|
9
|
+
/** The type symbol of one field of one method. */
|
|
10
|
+
export function fieldSymbol(pkg, namespace, method, field) {
|
|
11
|
+
return `${endpointId(pkg, namespace, method)}:${field}`;
|
|
12
|
+
}
|
|
13
|
+
/** The type symbol of a method's result. */
|
|
14
|
+
export function resultSymbol(pkg, namespace, method) {
|
|
15
|
+
return fieldSymbol(pkg, namespace, method, 'result');
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=typert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typert.js","sourceRoot":"","sources":["../../src/kit/typert.ts"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG,MAAM,UAAU,WAAW,CAAC,MAAe,EAAE,UAAkB;IAC7D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAA;AACrE,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,SAAiB,EAAE,MAAc;IACvE,OAAO,GAAG,GAAG,IAAI,SAAS,IAAI,MAAM,EAAE,CAAA;AACxC,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,SAAiB,EAAE,MAAc,EAAE,KAAa;IACvF,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,KAAK,EAAE,CAAA;AACzD,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,SAAiB,EAAE,MAAc;IACzE,OAAO,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AACtD,CAAC"}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The control-plane directory name under `home`. */
|
|
2
|
+
export declare const CONTROL_DIR = ".envinit";
|
|
3
|
+
/** Default path budget before the version segment switches to a short hash. */
|
|
4
|
+
export declare const DEFAULT_MAX_PATH = 200;
|
|
5
|
+
export declare function controlRoot(home: string): string;
|
|
6
|
+
export declare function lockPath(home: string): string;
|
|
7
|
+
export declare function statusLockPath(home: string): string;
|
|
8
|
+
export declare function layoutPath(home: string): string;
|
|
9
|
+
export declare function statusPath(home: string): string;
|
|
10
|
+
export declare function declaredPath(home: string): string;
|
|
11
|
+
export declare function tempRoot(home: string): string;
|
|
12
|
+
export declare function quarantineRoot(home: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* A staging directory for one install attempt under {@link tempRoot}.
|
|
15
|
+
* `sequence` must be monotonic per process.
|
|
16
|
+
*/
|
|
17
|
+
export declare function stagingDir(home: string, itemId: string, sequence: number): string;
|
|
18
|
+
/** A quarantine directory for one bad version directory. */
|
|
19
|
+
export declare function quarantineDir(home: string, sequence: number): string;
|
|
20
|
+
/** Is `child` inside `parent` (or equal to it)? Both are absolute and already normalised. */
|
|
21
|
+
export declare function isInside(parent: string, child: string): boolean;
|
|
22
|
+
/** Reject a `target.root` that is absolute or escapes `home` (`invalid-option`). */
|
|
23
|
+
export declare function assertSafeRelativeRoot(root: string): void;
|
|
24
|
+
/** Reject a provider-supplied relative path that is absolute or escapes its root. */
|
|
25
|
+
export declare function assertSafeRelativePath(path: string): void;
|
|
26
|
+
/** The version segment: the version, or a short hash when the path is too long. */
|
|
27
|
+
export declare function versionSegment(home: string, targetRoot: string, name: string, version: string, maxPathLength?: number): string;
|
|
28
|
+
//# sourceMappingURL=layout.d.ts.map
|