@shrkcrft/context-planner 0.1.0-alpha.21 → 0.1.0-alpha.23
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-context.d.ts","sourceRoot":"","sources":["../../src/planner/plan-context.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EAMlB,MAAM,2BAA2B,CAAC;AAInC,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,+DAA+D;IAC/D,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"plan-context.d.ts","sourceRoot":"","sources":["../../src/planner/plan-context.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EAMlB,MAAM,2BAA2B,CAAC;AAInC,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,+DAA+D;IAC/D,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAuHtE"}
|
|
@@ -30,6 +30,13 @@ export function planContext(options) {
|
|
|
30
30
|
...(options.hintedFiles ? { hintedFiles: options.hintedFiles } : {}),
|
|
31
31
|
...(options.hintedPackages ? { hintedPackages: options.hintedPackages } : {}),
|
|
32
32
|
});
|
|
33
|
+
// The graph exists but nothing scored: the pack would be silently empty.
|
|
34
|
+
// Tell the caller WHY (almost always a too-short / all-stop-word task, a
|
|
35
|
+
// typo, or a stale index) instead of returning a blank result with no hint.
|
|
36
|
+
if (scored.length === 0) {
|
|
37
|
+
diagnostics.push('no indexed file matched this task — it may be too short or all stop-words. ' +
|
|
38
|
+
'Try a more specific task, pass --hint-file/--hint-package, or refresh with `shrk graph index`.');
|
|
39
|
+
}
|
|
33
40
|
// 2. Estimate tokens (deterministic, BPE-ish approximation).
|
|
34
41
|
const ranked = scored
|
|
35
42
|
.slice(0, maxFiles * 3) // start with a generous pre-pool before budget pruning
|
|
@@ -26,11 +26,14 @@ export interface IRankerWeights {
|
|
|
26
26
|
hintedFile: number;
|
|
27
27
|
/** File belongs to a hinted package. */
|
|
28
28
|
hintedPackage: number;
|
|
29
|
-
/** File is a test for a ranked source file (followed-up only). */
|
|
30
|
-
testFollowup: number;
|
|
31
29
|
/** Penalty for generated files (subtract). */
|
|
32
30
|
generatedPenalty: number;
|
|
33
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Test-file weight, applied as a SIGNED term (`score -= testPenalty`). A
|
|
33
|
+
* positive value penalises test files (the default for non-bug-fix intents);
|
|
34
|
+
* a negative value boosts them (bug-fix sets `-0.2`, turning the term into a
|
|
35
|
+
* `+0.2` boost so a co-located test survives the cut).
|
|
36
|
+
*/
|
|
34
37
|
testPenalty: number;
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"score-files.d.ts","sourceRoot":"","sources":["../../src/ranker/score-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,MAAM,EAAE,UAAU,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,8BAA8B;IAC9B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,
|
|
1
|
+
{"version":3,"file":"score-files.d.ts","sourceRoot":"","sources":["../../src/ranker/score-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,MAAM,EAAE,UAAU,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,8BAA8B;IAC9B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAiBD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,SAAS,WAAW,EAAE,CAqDzF"}
|
|
@@ -3,7 +3,6 @@ const DEFAULT_WEIGHTS = {
|
|
|
3
3
|
symbolKeyword: 0.7,
|
|
4
4
|
hintedFile: 2.0,
|
|
5
5
|
hintedPackage: 0.5,
|
|
6
|
-
testFollowup: 0.4,
|
|
7
6
|
generatedPenalty: 0.6,
|
|
8
7
|
testPenalty: 0.3,
|
|
9
8
|
};
|
|
@@ -59,10 +58,13 @@ export function scoreFiles(api, input) {
|
|
|
59
58
|
reasons.push('generated (penalty)');
|
|
60
59
|
}
|
|
61
60
|
if ((node.tags ?? []).includes('test')) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
// Apply the test weight as a SIGNED term unconditionally. For most intents
|
|
62
|
+
// `testPenalty` is positive, so this subtracts (a real penalty). bug-fix
|
|
63
|
+
// tuning sets it negative, so `score -= (-0.2)` becomes a `+0.2` boost —
|
|
64
|
+
// previously the boost lived inside an `intent !== 'bug-fix'` guard and so
|
|
65
|
+
// never ran, leaving the bug-fix knob dead.
|
|
66
|
+
score -= weights.testPenalty;
|
|
67
|
+
reasons.push(weights.testPenalty < 0 ? 'test (intent-relevant boost)' : 'test (intent-mismatched penalty)');
|
|
66
68
|
}
|
|
67
69
|
if (score <= 0)
|
|
68
70
|
continue;
|
|
@@ -74,7 +76,7 @@ export function scoreFiles(api, input) {
|
|
|
74
76
|
function applyIntentTuning(intent) {
|
|
75
77
|
switch (intent) {
|
|
76
78
|
case 'bug-fix':
|
|
77
|
-
return {
|
|
79
|
+
return { testPenalty: -0.2 }; // negative weight = boost for co-located tests
|
|
78
80
|
case 'refactor':
|
|
79
81
|
return { symbolKeyword: 0.9 };
|
|
80
82
|
case 'docs':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/context-planner",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.23",
|
|
4
4
|
"description": "SharkCraft context planner: deterministic, token-budgeted context packs for AI coding agents. Combines code graph, rule-graph, and intent classification to pick the minimal relevant file set for a task.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
47
|
-
"@shrkcrft/graph": "^0.1.0-alpha.
|
|
48
|
-
"@shrkcrft/rule-graph": "^0.1.0-alpha.
|
|
46
|
+
"@shrkcrft/core": "^0.1.0-alpha.23",
|
|
47
|
+
"@shrkcrft/graph": "^0.1.0-alpha.23",
|
|
48
|
+
"@shrkcrft/rule-graph": "^0.1.0-alpha.23"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|