@shrkcrft/core 0.1.0-alpha.16 → 0.1.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/delegate/delegate-recipe.d.ts +54 -0
- package/dist/delegate/delegate-recipe.d.ts.map +1 -0
- package/dist/delegate/delegate-recipe.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/object/object-utils.d.ts.map +1 -1
- package/dist/object/object-utils.js +22 -6
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `IDelegateRecipe` contract — a fenced, mechanical task a local-LLM worker
|
|
3
|
+
* may produce edits for (see `shrk delegate`).
|
|
4
|
+
*
|
|
5
|
+
* Lives in `core` (not `config`) so BOTH the config loader AND the pack contract
|
|
6
|
+
* (`@shrkcrft/plugin-api`, which depends only on core) can reference it — a pack
|
|
7
|
+
* ships recipes via `delegateRecipeFiles`, the config declares them inline, and
|
|
8
|
+
* both resolve to this one type.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Routing hints for a delegate recipe (forward-compat; recipes are resolved by
|
|
12
|
+
* explicit `--recipe <id>` today). Kept primitive — no dependency on the
|
|
13
|
+
* higher-layer task router.
|
|
14
|
+
*/
|
|
15
|
+
export interface IDelegateRecipeMatch {
|
|
16
|
+
keywords?: readonly string[];
|
|
17
|
+
fileGlobs?: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/** A fenced, mechanical task a local-LLM worker may produce edits for. */
|
|
20
|
+
export interface IDelegateRecipe {
|
|
21
|
+
/** Stable id used by `shrk delegate run --recipe <id>`. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Human-readable label. */
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Optional routing hints (unused by the explicit-`--recipe` path). */
|
|
26
|
+
match?: IDelegateRecipeMatch;
|
|
27
|
+
/**
|
|
28
|
+
* Allow-list of globs the worker may touch. A target path matching NONE of
|
|
29
|
+
* these is refused before any write — the worker's blast radius is fenced.
|
|
30
|
+
*/
|
|
31
|
+
guardrailGlobs: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* `IPlannedOperation` kinds the worker may emit (e.g. `'export'`,
|
|
34
|
+
* `'ensure-import'`). An op of any other kind is dropped, never applied.
|
|
35
|
+
*/
|
|
36
|
+
allowedOps: readonly string[];
|
|
37
|
+
/** Local provider preference; defaults to the delegation block / `'auto'`. */
|
|
38
|
+
provider?: 'auto' | 'ollama' | 'llamacpp';
|
|
39
|
+
/** Model id passed to the provider. */
|
|
40
|
+
model?: string;
|
|
41
|
+
/** Max generate→verify attempts before escalating to a human. Default 2. */
|
|
42
|
+
maxAttempts?: number;
|
|
43
|
+
/** Per-attempt wall-clock budget (ms) for the model call. */
|
|
44
|
+
maxBudgetMs?: number;
|
|
45
|
+
/** Refuse delegation when the task risk exceeds this ceiling. */
|
|
46
|
+
riskCeiling?: 'low' | 'medium';
|
|
47
|
+
/**
|
|
48
|
+
* Deterministic verification ids run after the edit lands. Each MUST resolve
|
|
49
|
+
* to a `verificationCommands[].id` — this is the only way a recipe runs a
|
|
50
|
+
* verify command (a pack can never inject executable shell).
|
|
51
|
+
*/
|
|
52
|
+
verificationIds: readonly string[];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=delegate-recipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-recipe.d.ts","sourceRoot":"","sources":["../../src/delegate/delegate-recipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;OAGG;IACH,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC1C,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC/B;;;;OAIG;IACH,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `IDelegateRecipe` contract — a fenced, mechanical task a local-LLM worker
|
|
3
|
+
* may produce edits for (see `shrk delegate`).
|
|
4
|
+
*
|
|
5
|
+
* Lives in `core` (not `config`) so BOTH the config loader AND the pack contract
|
|
6
|
+
* (`@shrkcrft/plugin-api`, which depends only on core) can reference it — a pack
|
|
7
|
+
* ships recipes via `delegateRecipeFiles`, the config declares them inline, and
|
|
8
|
+
* both resolve to this one type.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
package/dist/index.d.ts
CHANGED
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,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../../src/object/object-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CASnD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI9E;
|
|
1
|
+
{"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../../src/object/object-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CASnD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI9E;AAiBD,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxF,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,GACH,CAAC,GAAG,CAAC,CAYP;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAUhG;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAShG;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAW9E;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAClD,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GACpB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAOhB"}
|
|
@@ -15,16 +15,29 @@ export function isPlainObject(value) {
|
|
|
15
15
|
const proto = Object.getPrototypeOf(value);
|
|
16
16
|
return proto === null || proto === Object.prototype;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Assign an own enumerable data property. Plain `target[key] = value` invokes
|
|
20
|
+
* the `Object.prototype.__proto__` setter for a key literally equal to
|
|
21
|
+
* `"__proto__"` (a real own key after `JSON.parse`), which silently drops the
|
|
22
|
+
* value (or pollutes the prototype) — so build these objects via defineProperty.
|
|
23
|
+
*/
|
|
24
|
+
function setOwn(target, key, value) {
|
|
25
|
+
Object.defineProperty(target, key, { value, writable: true, enumerable: true, configurable: true });
|
|
26
|
+
}
|
|
27
|
+
/** Read an OWN property value (returns undefined when the key isn't an own prop). */
|
|
28
|
+
function getOwn(obj, key) {
|
|
29
|
+
return Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
|
30
|
+
}
|
|
18
31
|
export function merge(a, b) {
|
|
19
32
|
const result = { ...a };
|
|
20
33
|
for (const key of Object.keys(b)) {
|
|
21
|
-
const av = result
|
|
34
|
+
const av = getOwn(result, key);
|
|
22
35
|
const bv = b[key];
|
|
23
36
|
if (isPlainObject(av) && isPlainObject(bv)) {
|
|
24
|
-
result
|
|
37
|
+
setOwn(result, key, merge(av, bv));
|
|
25
38
|
}
|
|
26
39
|
else if (bv !== undefined) {
|
|
27
|
-
result
|
|
40
|
+
setOwn(result, key, bv);
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
43
|
return result;
|
|
@@ -32,8 +45,11 @@ export function merge(a, b) {
|
|
|
32
45
|
export function pick(obj, keys) {
|
|
33
46
|
const result = {};
|
|
34
47
|
for (const key of keys) {
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
// Own-property check (not `key in obj`, which walks the prototype chain, so
|
|
49
|
+
// pick(obj, ['toString']) would otherwise copy the inherited function).
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
51
|
+
setOwn(result, key, obj[key]);
|
|
52
|
+
}
|
|
37
53
|
}
|
|
38
54
|
return result;
|
|
39
55
|
}
|
|
@@ -42,7 +58,7 @@ export function omit(obj, keys) {
|
|
|
42
58
|
const result = {};
|
|
43
59
|
for (const key of Object.keys(obj)) {
|
|
44
60
|
if (!keySet.has(key)) {
|
|
45
|
-
result
|
|
61
|
+
setOwn(result, key, obj[key]);
|
|
46
62
|
}
|
|
47
63
|
}
|
|
48
64
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.18",
|
|
4
4
|
"description": "SharkCraft core primitives: Result, AppError, logger, file-system abstraction, path/string/object utils, IDs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|