pi-harness-runtime 0.9.25 → 0.10.0
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/CHANGELOG.md +27 -7
- package/README.md +51 -51
- package/harness/auto-compact.ts +1 -1
- package/harness/autonomous-review.ts +88 -0
- package/harness/context-compact-orchestrator.ts +23 -23
- package/harness/context-window-manager.ts +5 -5
- package/harness/continue-prompt.ts +3 -3
- package/harness/e2e/minimax-quota-scraper.ts +1 -1
- package/harness/forked-summarizer.ts +4 -4
- package/harness/herdr-agents.ts +91 -0
- package/harness/index.ts +5 -5
- package/harness/loop-code-agent.ts +284 -0
- package/harness/loop-controller.ts +201 -0
- package/harness/loop-review-agent.ts +295 -0
- package/harness/loop-runtime.ts +10 -10
- package/harness/loop-types.ts +118 -0
- package/harness/notification-events.ts +3 -3
- package/harness/output-limit-handler.ts +1 -1
- package/harness/partial-recovery.ts +3 -3
- package/harness/session-memory.ts +5 -5
- package/index.ts +46 -32
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/a2a-adapter/src/types.ts +5 -5
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/dist/inbox.d.ts +3 -3
- package/packages/autonomous-runtime/dist/inbox.js +12 -12
- package/packages/autonomous-runtime/dist/lease.js +14 -14
- package/packages/autonomous-runtime/dist/types.js +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/autonomous-runtime/src/inbox.ts +12 -12
- package/packages/autonomous-runtime/src/lease.ts +15 -15
- package/packages/autonomous-runtime/src/types.ts +13 -13
- package/packages/autonomous-runtime/tsconfig.tsbuildinfo +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/dist/types.js +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/capability-registry/src/types.ts +5 -5
- package/packages/checkpoint/README.md +6 -6
- package/packages/checkpoint/dist/differ.js +2 -2
- package/packages/checkpoint/dist/engine.js +3 -3
- package/packages/checkpoint/dist/index.js +5 -5
- package/packages/checkpoint/dist/storage.js +3 -3
- package/packages/checkpoint/dist/types.js +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/checkpoint/src/differ.ts +2 -2
- package/packages/checkpoint/src/engine.ts +3 -3
- package/packages/checkpoint/src/index.ts +5 -5
- package/packages/checkpoint/src/storage.ts +3 -3
- package/packages/checkpoint/src/types.ts +10 -10
- package/packages/checkpoint/tsconfig.tsbuildinfo +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
- package/packages/clipboard/dist/src/clipboard.js +15 -7
- package/packages/clipboard/dist/src/clipboard.js.map +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard/src/clipboard.ts +16 -9
- package/packages/code-generation/README.md +13 -13
- package/packages/code-generation/dist/faker.js +4 -4
- package/packages/code-generation/dist/generator.js +3 -3
- package/packages/code-generation/dist/index.js +3 -3
- package/packages/code-generation/dist/templates/registry.js +1 -1
- package/packages/code-generation/dist/types.js +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-generation/src/faker.ts +5 -5
- package/packages/code-generation/src/generator.ts +4 -4
- package/packages/code-generation/src/index.ts +3 -3
- package/packages/code-generation/src/templates/registry.ts +1 -1
- package/packages/code-generation/src/types.ts +10 -10
- package/packages/code-generation/tsconfig.tsbuildinfo +1 -1
- package/packages/code-review/README.md +13 -13
- package/packages/code-review/dist/engine.js +3 -3
- package/packages/code-review/dist/index.js +3 -3
- package/packages/code-review/dist/types.js +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/code-review/src/engine.ts +3 -3
- package/packages/code-review/src/index.ts +3 -3
- package/packages/code-review/src/types.ts +10 -10
- package/packages/code-review/tsconfig.tsbuildinfo +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/context-compiler/dist/compiler.js +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-compiler/src/compiler.ts +1 -1
- package/packages/context-compiler/src/types.ts +11 -11
- package/packages/context-compiler/test/context-compiler.test.ts +11 -11
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cookie-sanitizer/README.md +27 -27
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/cost-optimizer/src/types.ts +5 -5
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/dist/analyzer.js +7 -7
- package/packages/django-plugin/package.json +1 -1
- package/packages/django-plugin/src/analyzer.ts +7 -7
- package/packages/doc-generator/package.json +1 -1
- package/packages/evaluation-engine/dist/engine.js +9 -9
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-engine/src/engine.ts +9 -9
- package/packages/evaluation-engine/src/types.ts +3 -3
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/dist/src/herdr-bus.d.ts +121 -0
- package/packages/event-bus/dist/src/herdr-bus.d.ts.map +1 -0
- package/packages/event-bus/dist/src/herdr-bus.js +322 -0
- package/packages/event-bus/dist/src/herdr-bus.js.map +1 -0
- package/packages/event-bus/dist/src/index.d.ts +2 -0
- package/packages/event-bus/dist/src/index.d.ts.map +1 -1
- package/packages/event-bus/dist/src/index.js +1 -0
- package/packages/event-bus/dist/src/index.js.map +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-bus/src/herdr-bus.ts +525 -0
- package/packages/event-bus/src/index.ts +29 -0
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/dist/replay.js +7 -7
- package/packages/experience-replay/package.json +1 -1
- package/packages/experience-replay/src/replay.ts +7 -7
- package/packages/experience-replay/src/types.ts +5 -5
- package/packages/feedback-collector/package.json +1 -1
- package/packages/framework-detector/README.md +18 -18
- package/packages/framework-detector/dist/detector.js +3 -3
- package/packages/framework-detector/dist/index.js +3 -3
- package/packages/framework-detector/dist/signatures/registry.js +24 -24
- package/packages/framework-detector/dist/types.js +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-detector/src/detector.ts +3 -3
- package/packages/framework-detector/src/index.ts +3 -3
- package/packages/framework-detector/src/signatures/registry.ts +24 -24
- package/packages/framework-detector/src/types.ts +7 -7
- package/packages/framework-detector/tsconfig.tsbuildinfo +1 -1
- package/packages/framework-plugin-sdk/README.md +23 -23
- package/packages/framework-plugin-sdk/dist/index.js +2 -2
- package/packages/framework-plugin-sdk/dist/manager.js +3 -3
- package/packages/framework-plugin-sdk/dist/types.js +2 -2
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/framework-plugin-sdk/src/index.ts +2 -2
- package/packages/framework-plugin-sdk/src/manager.ts +3 -3
- package/packages/framework-plugin-sdk/src/types.ts +10 -10
- package/packages/framework-plugin-sdk/tsconfig.tsbuildinfo +1 -1
- package/packages/frappe-plugin/dist/analyzer.js +8 -8
- package/packages/frappe-plugin/dist/types.js +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/frappe-plugin/src/analyzer.ts +8 -8
- package/packages/frappe-plugin/src/types.ts +10 -10
- package/packages/generic-web-plugin/dist/analyzer.js +5 -5
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/generic-web-plugin/src/analyzer.ts +5 -5
- package/packages/health-monitor/package.json +1 -1
- package/packages/health-monitor/src/monitor.ts +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/laravel-plugin/dist/analyzer.js +11 -11
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/laravel-plugin/src/analyzer.ts +11 -11
- package/packages/learning-engine/dist/engine.js +5 -5
- package/packages/learning-engine/dist/types.js +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/learning-engine/src/engine.ts +5 -5
- package/packages/learning-engine/src/types.ts +6 -6
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/dist/engine.js +8 -8
- package/packages/memory-engine/dist/types.js +2 -2
- package/packages/memory-engine/package.json +1 -1
- package/packages/memory-engine/src/engine.ts +8 -8
- package/packages/memory-engine/src/types.ts +9 -9
- package/packages/model-registry/package.json +1 -1
- package/packages/model-registry/src/types.ts +4 -4
- package/packages/nextjs-plugin/dist/analyzer.js +9 -9
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/nextjs-plugin/src/analyzer.ts +9 -9
- package/packages/notification/dist/notification-center.js +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/notification-center.ts +1 -1
- package/packages/observability/dist/alerts.js +2 -2
- package/packages/observability/dist/health.js +4 -4
- package/packages/observability/dist/index.js +6 -6
- package/packages/observability/dist/logger.js +7 -7
- package/packages/observability/dist/metrics.js +11 -11
- package/packages/observability/dist/tracer.js +3 -3
- package/packages/observability/dist/types.js +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/observability/src/alerts.ts +2 -2
- package/packages/observability/src/health.ts +4 -4
- package/packages/observability/src/index.ts +6 -6
- package/packages/observability/src/logger.ts +7 -7
- package/packages/observability/src/metrics.ts +11 -11
- package/packages/observability/src/tracer.ts +3 -3
- package/packages/observability/src/types.ts +7 -7
- package/packages/observability/test/observability.test.ts +4 -4
- package/packages/observability/tsconfig.tsbuildinfo +1 -1
- package/packages/performance-optimizer/dist/optimizer.js +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/performance-optimizer/src/optimizer.ts +1 -1
- package/packages/performance-optimizer/src/types.ts +4 -4
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/dist/analyzer.js +4 -4
- package/packages/project-analyzer/dist/index.js +8 -8
- package/packages/project-analyzer/dist/signals.js +3 -3
- package/packages/project-analyzer/dist/types.js +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-analyzer/src/analyzer.ts +4 -4
- package/packages/project-analyzer/src/index.ts +9 -9
- package/packages/project-analyzer/src/signals.ts +4 -4
- package/packages/project-analyzer/src/types.ts +15 -15
- package/packages/project-analyzer/test/index.test.ts +17 -17
- package/packages/project-analyzer/tsconfig.tsbuildinfo +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/dist/section-builder.js +1 -1
- package/packages/prompt-compiler/dist/types.js +3 -3
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-compiler/src/section-builder.ts +1 -1
- package/packages/prompt-compiler/src/types.ts +12 -12
- package/packages/prompt-compiler/test/prompt-compiler.test.ts +12 -12
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/dist/builder.js +1 -1
- package/packages/provider-adapter-sdk/dist/index.js +5 -5
- package/packages/provider-adapter-sdk/dist/registry.js +1 -1
- package/packages/provider-adapter-sdk/dist/tester.js +1 -1
- package/packages/provider-adapter-sdk/dist/types.js +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-adapter-sdk/src/builder.ts +1 -1
- package/packages/provider-adapter-sdk/src/index.ts +6 -6
- package/packages/provider-adapter-sdk/src/registry.ts +1 -1
- package/packages/provider-adapter-sdk/src/tester.ts +1 -1
- package/packages/provider-adapter-sdk/src/types.ts +5 -5
- package/packages/provider-adapter-sdk/tsconfig.tsbuildinfo +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-router/src/types.ts +4 -4
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/dist/deepagents-adapter.js +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/providers/src/deepagents-adapter.ts +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/dist/analyzer.js +7 -7
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/react-vite-plugin/src/analyzer.ts +7 -7
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/dist/compiler.js +17 -17
- package/packages/requirement-compiler/dist/types.js +2 -2
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/requirement-compiler/src/compiler.ts +17 -17
- package/packages/requirement-compiler/src/types.ts +21 -21
- package/packages/requirement-compiler/test/requirement-compiler.test.ts +17 -17
- package/packages/runtime/dist/command-executor.js +1 -1
- package/packages/runtime/dist/local-runtime-agent.js +1 -1
- package/packages/runtime/dist/policy-engine.js +1 -1
- package/packages/runtime/dist/runtime-api.js +1 -1
- package/packages/runtime/dist/workspace-manager.js +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/runtime/src/command-executor.ts +1 -1
- package/packages/runtime/src/local-runtime-agent.ts +1 -1
- package/packages/runtime/src/policy-engine.ts +1 -1
- package/packages/runtime/src/runtime-api.ts +1 -1
- package/packages/runtime/src/workspace-manager.ts +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/README.md +18 -18
- package/packages/session/dist/history.js +3 -3
- package/packages/session/dist/index.js +5 -5
- package/packages/session/dist/manager.js +3 -3
- package/packages/session/dist/policy.js +2 -2
- package/packages/session/dist/store.js +2 -2
- package/packages/session/dist/types.js +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session/src/history.ts +3 -3
- package/packages/session/src/index.ts +5 -5
- package/packages/session/src/manager.ts +3 -3
- package/packages/session/src/policy.ts +4 -4
- package/packages/session/src/store.ts +3 -3
- package/packages/session/src/types.ts +10 -10
- package/packages/session/tsconfig.tsbuildinfo +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skill-registry/src/types.ts +4 -4
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/dist/compiler.js +7 -7
- package/packages/task-compiler/dist/decompose.js +11 -11
- package/packages/task-compiler/dist/file-scope.js +6 -6
- package/packages/task-compiler/dist/graph.js +6 -6
- package/packages/task-compiler/dist/index.js +2 -2
- package/packages/task-compiler/dist/types.js +5 -5
- package/packages/task-compiler/dist/validate.js +2 -2
- package/packages/task-compiler/dist/verification.js +2 -2
- package/packages/task-compiler/package.json +1 -1
- package/packages/task-compiler/src/command-policy.ts +1 -1
- package/packages/task-compiler/src/compiler.ts +7 -7
- package/packages/task-compiler/src/decompose.ts +11 -11
- package/packages/task-compiler/src/file-scope.ts +6 -6
- package/packages/task-compiler/src/graph.ts +6 -6
- package/packages/task-compiler/src/index.ts +3 -3
- package/packages/task-compiler/src/types.ts +14 -14
- package/packages/task-compiler/src/validate.ts +2 -2
- package/packages/task-compiler/src/verification.ts +2 -2
- package/packages/task-compiler/test/task-compiler.test.ts +10 -10
- package/packages/test-data-generator/README.md +13 -13
- package/packages/test-data-generator/dist/faker-adapter.js +4 -4
- package/packages/test-data-generator/dist/generator.js +3 -3
- package/packages/test-data-generator/dist/index.js +3 -3
- package/packages/test-data-generator/dist/types.js +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-data-generator/src/faker-adapter.ts +4 -4
- package/packages/test-data-generator/src/generator.ts +3 -3
- package/packages/test-data-generator/src/index.ts +3 -3
- package/packages/test-data-generator/src/types.ts +9 -9
- package/packages/test-data-generator/tsconfig.tsbuildinfo +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/types/src/agent-worker-types.ts +5 -5
- package/packages/types/src/runtime-types.ts +12 -12
- package/packages/types/tsconfig.tsbuildinfo +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/renderer.ts +7 -7
- package/skills/harness-runtime/SKILL.md +15 -15
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Every selected item has a source reference; every omitted item has a reason.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// --- Context candidate kinds -------------------------------------------
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Kinds of context that can be collected.
|
|
@@ -24,7 +24,7 @@ export type ContextKind =
|
|
|
24
24
|
*/
|
|
25
25
|
export type ContextTrust = "authoritative" | "generated" | "unverified";
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// --- Candidate --------------------------------------------------------
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* A raw context candidate from a source collector.
|
|
@@ -49,7 +49,7 @@ export interface ContextCandidate {
|
|
|
49
49
|
symbols?: string[];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// --- Omission ---------------------------------------------------------
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Reasons why a candidate was omitted.
|
|
@@ -76,7 +76,7 @@ export interface OmittedItem {
|
|
|
76
76
|
deniedBy?: string;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
//
|
|
79
|
+
// --- Compiled item ----------------------------------------------------
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* An item that made it into the final compiled context.
|
|
@@ -97,7 +97,7 @@ export interface CompiledContextItem {
|
|
|
97
97
|
symbols?: string[];
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
//
|
|
100
|
+
// --- Source graph -----------------------------------------------------
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* An edge in the context source graph.
|
|
@@ -109,7 +109,7 @@ export interface ContextSourceEdge {
|
|
|
109
109
|
weight: number;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
//
|
|
112
|
+
// --- Compiled context --------------------------------------------------
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* The final compiled context output.
|
|
@@ -125,7 +125,7 @@ export interface CompiledContext {
|
|
|
125
125
|
mapping: Record<string, string>;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
//
|
|
128
|
+
// --- Scoring ---------------------------------------------------------
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Scoring weights for context candidates.
|
|
@@ -151,7 +151,7 @@ export const DEFAULT_SCORING_WEIGHTS: ScoringWeights = {
|
|
|
151
151
|
duplicationPenalty: 8,
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
//
|
|
154
|
+
// --- Policy ---------------------------------------------------------
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Policy rules for context selection.
|
|
@@ -183,7 +183,7 @@ export const DEFAULT_POLICY: ContextPolicy = {
|
|
|
183
183
|
maxFileBytes: 200_000,
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
//
|
|
186
|
+
// --- Compile request ------------------------------------------------
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
189
|
* Input to the context compiler.
|
|
@@ -199,7 +199,7 @@ export interface ContextCompileRequest {
|
|
|
199
199
|
policy?: Partial<ContextPolicy>;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
//
|
|
202
|
+
// --- Invalidation ---------------------------------------------------
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Reasons for context invalidation.
|
|
@@ -218,7 +218,7 @@ export interface ContextInvalidation {
|
|
|
218
218
|
details?: Record<string, unknown>;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
//
|
|
221
|
+
// --- Error codes ----------------------------------------------------
|
|
222
222
|
|
|
223
223
|
export type ContextCompileErrorCode =
|
|
224
224
|
| "MISSING_REQUIRED_SOURCE"
|
|
@@ -33,7 +33,7 @@ import type {
|
|
|
33
33
|
ContextPolicy,
|
|
34
34
|
} from "../src/types.js";
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// --- Test fixtures -------------------------------------------------------
|
|
37
37
|
|
|
38
38
|
function makeCandidate(
|
|
39
39
|
overrides?: Partial<ContextCandidate>,
|
|
@@ -64,7 +64,7 @@ function makeRequest(
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
//
|
|
67
|
+
// --- AC-1: Required project rules always included ------------------------
|
|
68
68
|
|
|
69
69
|
describe("AC-1: Required project rules always included", () => {
|
|
70
70
|
it("includes required project_rule even when budget is tiny", async () => {
|
|
@@ -111,7 +111,7 @@ describe("AC-1: Required project rules always included", () => {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
//
|
|
114
|
+
// --- AC-2: .env content denied ------------------------------------------
|
|
115
115
|
|
|
116
116
|
describe("AC-2: .env content denied by policy", () => {
|
|
117
117
|
it("denies .env file content", () => {
|
|
@@ -161,7 +161,7 @@ describe("AC-2: .env content denied by policy", () => {
|
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
//
|
|
164
|
+
// --- AC-3: Broken optional OKF link does not fail compilation -------------
|
|
165
165
|
|
|
166
166
|
describe("AC-3: Broken optional OKF link does not fail compilation", () => {
|
|
167
167
|
it("does not throw when optional OKF has no content", async () => {
|
|
@@ -189,7 +189,7 @@ describe("AC-3: Broken optional OKF link does not fail compilation", () => {
|
|
|
189
189
|
});
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
//
|
|
192
|
+
// --- AC-4: Broken required source fails compilation ----------------------
|
|
193
193
|
|
|
194
194
|
describe("AC-4: Broken required source fails compilation", () => {
|
|
195
195
|
it("throws MISSING_REQUIRED_SOURCE when required source has no content", async () => {
|
|
@@ -227,7 +227,7 @@ describe("AC-4: Broken required source fails compilation", () => {
|
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
-
//
|
|
230
|
+
// --- AC-5: Duplicate source slices merged -------------------------------
|
|
231
231
|
|
|
232
232
|
describe("AC-5: Duplicate source slices merged", () => {
|
|
233
233
|
it("merges slices from the same file", () => {
|
|
@@ -319,7 +319,7 @@ describe("AC-5: Duplicate source slices merged", () => {
|
|
|
319
319
|
});
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
-
//
|
|
322
|
+
// --- AC-6: Context under token budget -----------------------------------
|
|
323
323
|
|
|
324
324
|
describe("AC-6: Context remains under requested token budget", () => {
|
|
325
325
|
it("fits within budget when content is small enough", async () => {
|
|
@@ -380,7 +380,7 @@ describe("AC-6: Context remains under requested token budget", () => {
|
|
|
380
380
|
});
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
-
//
|
|
383
|
+
// --- AC-7: Changed file hash invalidates cache ---------------------------
|
|
384
384
|
|
|
385
385
|
describe("AC-7: Changed file hash invalidates cache", () => {
|
|
386
386
|
it("source_hash_changed invalidates when hash differs", () => {
|
|
@@ -478,7 +478,7 @@ describe("AC-7: Changed file hash invalidates cache", () => {
|
|
|
478
478
|
});
|
|
479
479
|
});
|
|
480
480
|
|
|
481
|
-
//
|
|
481
|
+
// --- AC-8: Identical repo state → identical compiled context -------------
|
|
482
482
|
|
|
483
483
|
describe("AC-8: Identical repository state produces identical compiled context", () => {
|
|
484
484
|
it("same candidates produce same cache key", () => {
|
|
@@ -550,7 +550,7 @@ describe("AC-8: Identical repository state produces identical compiled context",
|
|
|
550
550
|
});
|
|
551
551
|
});
|
|
552
552
|
|
|
553
|
-
//
|
|
553
|
+
// --- AC-9: Omitted items include explicit reasons ----------------------
|
|
554
554
|
|
|
555
555
|
describe("AC-9: Omitted items include explicit reasons", () => {
|
|
556
556
|
it("policy denied items have reason=policy_denied", async () => {
|
|
@@ -619,7 +619,7 @@ describe("AC-9: Omitted items include explicit reasons", () => {
|
|
|
619
619
|
});
|
|
620
620
|
});
|
|
621
621
|
|
|
622
|
-
//
|
|
622
|
+
// --- Additional coverage -------------------------------------------------
|
|
623
623
|
|
|
624
624
|
describe("mergePolicy", () => {
|
|
625
625
|
it("merges user policy with defaults", () => {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# @pi-harness/cookie-sanitizer
|
|
2
2
|
|
|
3
|
-
> Forgiving input
|
|
3
|
+
> Forgiving input -> strict canonical cache for provider-quota mirroring.
|
|
4
4
|
|
|
5
5
|
A normalization boundary that lets users drop **any** cookie file (any name, any format) into a known folder, and turns it into a single standard Netscape file the rest of the runtime can rely on.
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
~/.pi-harness-runtime/cookies/
|
|
9
|
-
|
|
8
|
+
~/.pi-harness-runtime/cookies/ <- user drops anything here
|
|
9
|
+
|
|
|
10
10
|
▼
|
|
11
|
-
Cookie Sanitizer
|
|
12
|
-
|
|
11
|
+
Cookie Sanitizer <- THIS PACKAGE
|
|
12
|
+
|
|
|
13
13
|
▼
|
|
14
|
-
~/.config/<provider>-cookies.txt
|
|
15
|
-
|
|
14
|
+
~/.config/<provider>-cookies.txt <- canonical, runtime-owned
|
|
15
|
+
|
|
|
16
16
|
▼
|
|
17
|
-
MiniMaxQuotaScraper (unchanged)
|
|
17
|
+
MiniMaxQuotaScraper (unchanged) <- reads only the canonical
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Why
|
|
@@ -30,8 +30,8 @@ The previous design expected users to know the exact path (`~/.config/minimax-co
|
|
|
30
30
|
|
|
31
31
|
**File names** — any name in the drop folder. Inference prefers:
|
|
32
32
|
|
|
33
|
-
1. Filename hint (`minimax-*.txt`, `*claude*`, etc.)
|
|
34
|
-
2. Dominant cookie domain (≥ 80% match)
|
|
33
|
+
1. Filename hint (`minimax-*.txt`, `*claude*`, etc.) -> provider
|
|
34
|
+
2. Dominant cookie domain (≥ 80% match) -> provider
|
|
35
35
|
3. `providerHint` option overrides all of the above
|
|
36
36
|
|
|
37
37
|
**Provider scope** — currently shipping with: `minimax`, `anthropic`, `openai`, `glm`, `openrouter`. The registry is open and inference by domain works for any provider whose cookies are in the drop folder.
|
|
@@ -46,7 +46,7 @@ import { sync } from "@pi-harness/cookie-sanitizer";
|
|
|
46
46
|
const result = sync();
|
|
47
47
|
|
|
48
48
|
if (result.wrote) {
|
|
49
|
-
console.log(`Synced ${result.totalCookies} cookies for ${result.provider}
|
|
49
|
+
console.log(`Synced ${result.totalCookies} cookies for ${result.provider} -> ${result.cachePath}`);
|
|
50
50
|
} else {
|
|
51
51
|
console.log(`No-op: ${result.errors[0]?.message ?? "nothing to sync"}`);
|
|
52
52
|
}
|
|
@@ -60,7 +60,7 @@ import { CookieWatcher } from "@pi-harness/cookie-sanitizer";
|
|
|
60
60
|
const watcher = new CookieWatcher({
|
|
61
61
|
dropDir: "~/.pi-harness-runtime/cookies",
|
|
62
62
|
onEvent: (e) => {
|
|
63
|
-
if (e.kind === "sync-ok") console.log(`Synced ${e.cookies} cookies
|
|
63
|
+
if (e.kind === "sync-ok") console.log(`Synced ${e.cookies} cookies -> ${e.cachePath}`);
|
|
64
64
|
if (e.kind === "sync-error") console.error(`Sync error: ${e.message}`);
|
|
65
65
|
},
|
|
66
66
|
});
|
|
@@ -115,23 +115,23 @@ bun test test/sync.test.ts
|
|
|
115
115
|
|
|
116
116
|
```
|
|
117
117
|
src/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
+-- index.ts # public API surface
|
|
119
|
+
+-- types.ts # canonical types
|
|
120
|
+
+-- detect-format.ts # Netscape vs JSON detection
|
|
121
|
+
+-- parse-netscape.ts # Netscape parser + serializer
|
|
122
|
+
+-- parse-json.ts # EditThisCookie JSON parser
|
|
123
|
+
+-- normalize.ts # dedupe, expire, domain-match
|
|
124
|
+
+-- infer-provider.ts # filename + domain inference
|
|
125
|
+
+-- atomic-write.ts # POSIX atomic write
|
|
126
|
+
+-- sync.ts # orchestrator
|
|
127
|
+
+-- watcher.ts # chokidar v5 wrapper
|
|
128
128
|
|
|
129
129
|
test/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
+-- parse.test.ts # 14 cases — Netscape + JSON
|
|
131
|
+
+-- normalize.test.ts # 12 cases — dedupe/expire/domain
|
|
132
|
+
+-- infer.test.ts # 13 cases — filename + domain + combined
|
|
133
|
+
+-- sync.test.ts # 12 cases — end-to-end
|
|
134
|
+
+-- watcher.test.ts # 2 cases — config sanity (chokidar is exercised live)
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
## Limitations
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Re-export Currency type
|
|
6
6
|
export type Currency = "USD" | "THB";
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// --- Cost Entry Types -------------------------------------------------
|
|
9
9
|
|
|
10
10
|
export interface CostEntry {
|
|
11
11
|
id: string;
|
|
@@ -20,7 +20,7 @@ export interface CostEntry {
|
|
|
20
20
|
timestamp: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
//
|
|
23
|
+
// --- Budget Types -----------------------------------------------------
|
|
24
24
|
|
|
25
25
|
export interface CostBudget {
|
|
26
26
|
daily?: number;
|
|
@@ -53,7 +53,7 @@ export interface CostPeriod {
|
|
|
53
53
|
type: "day" | "week" | "month" | "custom";
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
//
|
|
56
|
+
// --- Optimization Types ------------------------------------------------
|
|
57
57
|
|
|
58
58
|
export interface CostOptimizerConfig {
|
|
59
59
|
defaultBudget: CostBudget;
|
|
@@ -99,7 +99,7 @@ export interface OptimizedSelection {
|
|
|
99
99
|
tradeoffs: string[];
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
//
|
|
102
|
+
// --- Optimizer Interface ---------------------------------------------
|
|
103
103
|
|
|
104
104
|
export interface CostOptimizer {
|
|
105
105
|
trackCost(entry: Omit<CostEntry, "id" | "timestamp">): CostEntry;
|
|
@@ -118,7 +118,7 @@ export interface CostOptimizer {
|
|
|
118
118
|
): OptimizedSelection[];
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
//
|
|
121
|
+
// --- Event Types -----------------------------------------------------
|
|
122
122
|
|
|
123
123
|
export type CostOptimizerEvent =
|
|
124
124
|
| { type: "cost.tracked"; entryId: string; cost: number; total: number }
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { readdir, readFile } from "node:fs/promises";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
-
//
|
|
9
|
+
// --- Detection ---------------------------------------------------------------
|
|
10
10
|
function isDjangoWorkspace(root) {
|
|
11
11
|
return (existsSync(join(root, "manage.py")) ||
|
|
12
12
|
(existsSync(join(root, "settings.py")) &&
|
|
@@ -14,7 +14,7 @@ function isDjangoWorkspace(root) {
|
|
|
14
14
|
(existsSync(join(root, "requirements.txt")) &&
|
|
15
15
|
existsSync(join(root, "manage.py"))));
|
|
16
16
|
}
|
|
17
|
-
//
|
|
17
|
+
// --- Version ----------------------------------------------------------------
|
|
18
18
|
async function detectVersion(root) {
|
|
19
19
|
try {
|
|
20
20
|
const content = await readFile(join(root, "requirements.txt"), "utf-8");
|
|
@@ -42,7 +42,7 @@ async function detectVersion(root) {
|
|
|
42
42
|
}
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
|
-
//
|
|
45
|
+
// --- Settings Parser ---------------------------------------------------------
|
|
46
46
|
async function parseSettings(root) {
|
|
47
47
|
const installedApps = [];
|
|
48
48
|
const middleware = [];
|
|
@@ -90,7 +90,7 @@ async function parseSettings(root) {
|
|
|
90
90
|
}
|
|
91
91
|
return { installedApps, middleware };
|
|
92
92
|
}
|
|
93
|
-
//
|
|
93
|
+
// --- Django App Scanner -----------------------------------------------------
|
|
94
94
|
async function scanDjangoApps(root) {
|
|
95
95
|
const apps = [];
|
|
96
96
|
// Django project apps can be:
|
|
@@ -153,7 +153,7 @@ async function scanDjangoApps(root) {
|
|
|
153
153
|
}
|
|
154
154
|
return apps;
|
|
155
155
|
}
|
|
156
|
-
//
|
|
156
|
+
// --- Management Commands ----------------------------------------------------
|
|
157
157
|
async function findManagementCommands(root) {
|
|
158
158
|
const commands = [];
|
|
159
159
|
// Simple recursive scan for management/commands directories
|
|
@@ -191,7 +191,7 @@ async function findManagementCommands(root) {
|
|
|
191
191
|
}
|
|
192
192
|
return [...new Set(commands)];
|
|
193
193
|
}
|
|
194
|
-
//
|
|
194
|
+
// --- Requirements -----------------------------------------------------------
|
|
195
195
|
async function parseRequirements(root) {
|
|
196
196
|
const reqPath = join(root, "requirements.txt");
|
|
197
197
|
if (!existsSync(reqPath))
|
|
@@ -208,7 +208,7 @@ async function parseRequirements(root) {
|
|
|
208
208
|
return [];
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
//
|
|
211
|
+
// --- Main Analyzer ---------------------------------------------------------
|
|
212
212
|
export async function analyzeDjango(root) {
|
|
213
213
|
if (!isDjangoWorkspace(root))
|
|
214
214
|
return null;
|
|
@@ -9,7 +9,7 @@ import { readdir, readFile } from "node:fs/promises";
|
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import type { DjangoAnalysis, DjangoApp, ConfigFile } from "./types.js";
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// --- Detection ---------------------------------------------------------------
|
|
13
13
|
|
|
14
14
|
function isDjangoWorkspace(root: string): boolean {
|
|
15
15
|
return (
|
|
@@ -21,7 +21,7 @@ function isDjangoWorkspace(root: string): boolean {
|
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// --- Version ----------------------------------------------------------------
|
|
25
25
|
|
|
26
26
|
async function detectVersion(root: string): Promise<string | undefined> {
|
|
27
27
|
try {
|
|
@@ -48,7 +48,7 @@ async function detectVersion(root: string): Promise<string | undefined> {
|
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
//
|
|
51
|
+
// --- Settings Parser ---------------------------------------------------------
|
|
52
52
|
|
|
53
53
|
async function parseSettings(root: string): Promise<{
|
|
54
54
|
installedApps: string[];
|
|
@@ -110,7 +110,7 @@ async function parseSettings(root: string): Promise<{
|
|
|
110
110
|
return { installedApps, middleware };
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
//
|
|
113
|
+
// --- Django App Scanner -----------------------------------------------------
|
|
114
114
|
|
|
115
115
|
async function scanDjangoApps(root: string): Promise<DjangoApp[]> {
|
|
116
116
|
const apps: DjangoApp[] = [];
|
|
@@ -180,7 +180,7 @@ async function scanDjangoApps(root: string): Promise<DjangoApp[]> {
|
|
|
180
180
|
return apps;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
//
|
|
183
|
+
// --- Management Commands ----------------------------------------------------
|
|
184
184
|
|
|
185
185
|
async function findManagementCommands(root: string): Promise<string[]> {
|
|
186
186
|
const commands: string[] = [];
|
|
@@ -219,7 +219,7 @@ async function findManagementCommands(root: string): Promise<string[]> {
|
|
|
219
219
|
return [...new Set(commands)];
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
//
|
|
222
|
+
// --- Requirements -----------------------------------------------------------
|
|
223
223
|
|
|
224
224
|
async function parseRequirements(root: string): Promise<string[]> {
|
|
225
225
|
const reqPath = join(root, "requirements.txt");
|
|
@@ -237,7 +237,7 @@ async function parseRequirements(root: string): Promise<string[]> {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
//
|
|
240
|
+
// --- Main Analyzer ---------------------------------------------------------
|
|
241
241
|
|
|
242
242
|
export async function analyzeDjango(
|
|
243
243
|
root: string,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { DEFAULT_SCORING_WEIGHTS } from "./types.js";
|
|
8
|
-
//
|
|
8
|
+
// --- Evidence Collection -------------------------------------------------------
|
|
9
9
|
function collectEvidence(outputs, testResults, policyFindings) {
|
|
10
10
|
const evidence = [];
|
|
11
11
|
// Add test results as evidence
|
|
@@ -38,7 +38,7 @@ function collectEvidence(outputs, testResults, policyFindings) {
|
|
|
38
38
|
}
|
|
39
39
|
return evidence;
|
|
40
40
|
}
|
|
41
|
-
//
|
|
41
|
+
// --- Missing Output Detection --------------------------------------------------
|
|
42
42
|
function findMissingOutputs(requiredArtifacts, outputs) {
|
|
43
43
|
const findings = [];
|
|
44
44
|
const outputPaths = new Set(outputs.filter((o) => o.path).map((o) => o.path));
|
|
@@ -57,7 +57,7 @@ function findMissingOutputs(requiredArtifacts, outputs) {
|
|
|
57
57
|
}
|
|
58
58
|
return findings;
|
|
59
59
|
}
|
|
60
|
-
//
|
|
60
|
+
// --- Test Analysis ------------------------------------------------------------
|
|
61
61
|
function analyzeTests(testResults) {
|
|
62
62
|
const findings = [];
|
|
63
63
|
let passedCount = 0;
|
|
@@ -87,7 +87,7 @@ function analyzeTests(testResults) {
|
|
|
87
87
|
}
|
|
88
88
|
return { findings, passedCount, totalCount, hasFailures };
|
|
89
89
|
}
|
|
90
|
-
//
|
|
90
|
+
// --- Policy Analysis ----------------------------------------------------------
|
|
91
91
|
function analyzePolicies(policyFindings) {
|
|
92
92
|
const findings = [];
|
|
93
93
|
const criticalFindings = [];
|
|
@@ -106,7 +106,7 @@ function analyzePolicies(policyFindings) {
|
|
|
106
106
|
}
|
|
107
107
|
return { findings, criticalFindings };
|
|
108
108
|
}
|
|
109
|
-
//
|
|
109
|
+
// --- Acceptance Criteria Coverage ---------------------------------------------
|
|
110
110
|
function analyzeAcceptanceCoverage(acceptanceCriteria, outputs, testResults) {
|
|
111
111
|
const findings = [];
|
|
112
112
|
const coveredCriteria = [];
|
|
@@ -148,7 +148,7 @@ function analyzeAcceptanceCoverage(acceptanceCriteria, outputs, testResults) {
|
|
|
148
148
|
: 100;
|
|
149
149
|
return { findings, coverage, unmetCriteria };
|
|
150
150
|
}
|
|
151
|
-
//
|
|
151
|
+
// --- Scoring -----------------------------------------------------------------
|
|
152
152
|
function calculateScore(weights, testAnalysis, acceptanceCoverage, criticalPolicies, securityFindings, regressionFindings) {
|
|
153
153
|
const breakdown = {};
|
|
154
154
|
// Correctness (30%) - based on missing outputs
|
|
@@ -188,7 +188,7 @@ function calculateScore(weights, testAnalysis, acceptanceCoverage, criticalPolic
|
|
|
188
188
|
regressionPenalty));
|
|
189
189
|
return { score: Math.round(totalScore), breakdown };
|
|
190
190
|
}
|
|
191
|
-
//
|
|
191
|
+
// --- Failure Classification ---------------------------------------------------
|
|
192
192
|
function classifyFailure(findings) {
|
|
193
193
|
const classes = [];
|
|
194
194
|
for (const finding of findings) {
|
|
@@ -226,7 +226,7 @@ function classifyFailure(findings) {
|
|
|
226
226
|
}
|
|
227
227
|
return classes;
|
|
228
228
|
}
|
|
229
|
-
//
|
|
229
|
+
// --- Main Engine ---------------------------------------------------------------
|
|
230
230
|
export class EvaluationEngine {
|
|
231
231
|
weights;
|
|
232
232
|
state = "pending";
|
|
@@ -337,7 +337,7 @@ export class EvaluationEngine {
|
|
|
337
337
|
this.state = "pending";
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
//
|
|
340
|
+
// --- Factory -----------------------------------------------------------------
|
|
341
341
|
export function createEvaluationEngine(weights) {
|
|
342
342
|
return new EvaluationEngine(weights);
|
|
343
343
|
}
|