@wrongstack/core 0.109.1 → 0.119.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.
Files changed (62) hide show
  1. package/dist/{agent-bridge-mOxbpFcg.d.ts → agent-bridge-PRAbEX-9.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DukQLUcS.d.ts → agent-subagent-runner-DXWImnNV.d.ts} +7 -8
  3. package/dist/{brain-Dfv4Y82E.d.ts → brain-NZZqL8sn.d.ts} +1 -1
  4. package/dist/{compactor-DXLxLcmU.d.ts → compactor-C3stu664.d.ts} +1 -1
  5. package/dist/{config-BSU-6vah.d.ts → config-DZV9VK9n.d.ts} +104 -3
  6. package/dist/{context-CNRYfhUv.d.ts → context-hvXINa6a.d.ts} +31 -1
  7. package/dist/coordination/index.d.ts +12 -13
  8. package/dist/coordination/index.js +198 -0
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -27
  11. package/dist/defaults/index.js +243 -35
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +15 -16
  14. package/dist/execution/index.js +209 -5
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -7
  17. package/dist/{goal-preamble-CI8lxeY1.d.ts → goal-preamble-COpt55W8.d.ts} +10 -10
  18. package/dist/{index-DIKEcfgC.d.ts → index-4VVHuTZF.d.ts} +7 -6
  19. package/dist/{index-BWRN6wOb.d.ts → index-Cj3le7TI.d.ts} +9 -10
  20. package/dist/index.d.ts +40 -41
  21. package/dist/index.js +298 -43
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -7
  24. package/dist/kernel/index.d.ts +10 -11
  25. package/dist/llm-selector-Bmx4PsVM.d.ts +58 -0
  26. package/dist/{mcp-servers-CXCsANdY.d.ts → mcp-servers-CofNHOqn.d.ts} +3 -3
  27. package/dist/{mode-ARA3HrkY.d.ts → mode-CZlO9iU1.d.ts} +1 -1
  28. package/dist/models/index.d.ts +157 -53
  29. package/dist/models/index.js +423 -1
  30. package/dist/models/index.js.map +1 -1
  31. package/dist/{models-registry-DU64QxQa.d.ts → models-registry-BzlsjKcy.d.ts} +1 -1
  32. package/dist/{multi-agent-coordinator-51LvnXkD.d.ts → multi-agent-coordinator-CmDmUgq2.d.ts} +1 -1
  33. package/dist/{null-fleet-bus-D09hMzFQ.d.ts → null-fleet-bus-CyH2YqP4.d.ts} +6 -6
  34. package/dist/observability/index.d.ts +2 -2
  35. package/dist/{parallel-eternal-engine-B2CbsKpc.d.ts → parallel-eternal-engine-uxVm4y4V.d.ts} +8 -8
  36. package/dist/{path-resolver-DDJiMAtX.d.ts → path-resolver-gfoGxpdd.d.ts} +3 -3
  37. package/dist/{permission-BDv7z0mk.d.ts → permission-DhLrgA30.d.ts} +1 -1
  38. package/dist/{permission-policy-dF74EpDp.d.ts → permission-policy-DGOvne7i.d.ts} +2 -2
  39. package/dist/{pipeline-BqiA_UMr.d.ts → pipeline-CqF7uju2.d.ts} +2 -2
  40. package/dist/{plan-templates-BdDxl9cI.d.ts → plan-templates-DoKhzenv.d.ts} +6 -6
  41. package/dist/{provider-runner-BUunikwY.d.ts → provider-runner-BPlI5sPZ.d.ts} +3 -3
  42. package/dist/{retry-policy-BcmuT_V0.d.ts → retry-policy-B4Q-FZgE.d.ts} +1 -1
  43. package/dist/sdd/index.d.ts +8 -9
  44. package/dist/sdd/index.js +198 -0
  45. package/dist/sdd/index.js.map +1 -1
  46. package/dist/{secret-vault-DrOhc2i5.d.ts → secret-vault-B7GnL6o9.d.ts} +1 -1
  47. package/dist/security/index.d.ts +4 -4
  48. package/dist/{selector-C7wcdqMA.d.ts → selector-BakeMnWR.d.ts} +1 -1
  49. package/dist/{session-event-bridge-BpJ5trO9.d.ts → session-event-bridge-DE5Oekwx.d.ts} +1 -1
  50. package/dist/{session-reader-DDz1Ek4V.d.ts → session-reader-DFC81-4p.d.ts} +1 -1
  51. package/dist/storage/index.d.ts +11 -12
  52. package/dist/storage/index.js +43 -34
  53. package/dist/storage/index.js.map +1 -1
  54. package/dist/types/index.d.ts +19 -20
  55. package/dist/types/index.js +35 -1
  56. package/dist/types/index.js.map +1 -1
  57. package/dist/utils/index.d.ts +3 -4
  58. package/dist/utils/index.js +2 -1
  59. package/dist/utils/index.js.map +1 -1
  60. package/dist/{wstack-paths-_lqjzErq.d.ts → wstack-paths-DD50Omgn.d.ts} +3 -0
  61. package/package.json +1 -1
  62. package/dist/models-registry-B6_KfS65.d.ts +0 -95
@@ -1,42 +1,41 @@
1
1
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-B9J5puGM.js';
2
- export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, k as MemoryStoreOptions, l as MigrationContext, m as MigrationResult, P as PersistedQueueItem, n as PlanFile, o as PlanItem, p as PlanTemplate, Q as QueueStore, R as RecoveryLock, q as RecoveryLockOptions, S as SessionAnalyzer, r as SessionStoreOptions, T as TodosCheckpointFile, s as addPlanItem, t as attachPlanCheckpoint, u as attachTodosCheckpoint, v as clearPlan, w as deriveTodosFromPlanItem, x as emptyPlan, y as formatPlan, z as formatPlanTemplates, B as getPlanTemplate, E as listPlanTemplates, G as loadPlan, H as loadTodosCheckpoint, J as removePlanItem, K as runConfigMigrations, L as savePlan, N as saveTodosCheckpoint, O as setPlanItemStatus } from '../plan-templates-BdDxl9cI.js';
3
- export { D as DefaultSessionReader } from '../session-reader-DDz1Ek4V.js';
4
- export { A as AuditLevel, S as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-BpJ5trO9.js';
2
+ export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, k as MemoryStoreOptions, l as MigrationContext, m as MigrationResult, P as PersistedQueueItem, n as PlanFile, o as PlanItem, p as PlanTemplate, Q as QueueStore, R as RecoveryLock, q as RecoveryLockOptions, S as SessionAnalyzer, r as SessionStoreOptions, T as TodosCheckpointFile, s as addPlanItem, t as attachPlanCheckpoint, u as attachTodosCheckpoint, v as clearPlan, w as deriveTodosFromPlanItem, x as emptyPlan, y as formatPlan, z as formatPlanTemplates, B as getPlanTemplate, E as listPlanTemplates, G as loadPlan, H as loadTodosCheckpoint, J as removePlanItem, K as runConfigMigrations, L as savePlan, N as saveTodosCheckpoint, O as setPlanItemStatus } from '../plan-templates-DoKhzenv.js';
3
+ export { D as DefaultSessionReader } from '../session-reader-DFC81-4p.js';
4
+ export { A as AuditLevel, S as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-DE5Oekwx.js';
5
5
  export { a as DirectorStateCheckpoint, D as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BfeCUbmk.js';
6
- export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-vault-DrOhc2i5.js';
7
- export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from '../permission-policy-dF74EpDp.js';
8
- export { C as CompactorOptions, D as DefaultErrorHandler, a as DefaultRetryPolicy, E as EternalAutonomyEngine, b as EternalAutonomyOptions, c as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, d as ParallelEternalEngine, e as ParallelEternalOptions, f as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-B2CbsKpc.js';
9
- export { A as AutoCompactionMiddleware, a as AutonomousRunner, b as AutonomousRunnerOptions, c as AutonomyPromptContributorOptions, D as DefaultSkillLoader, d as DoneCheckResult, e as DoneConditionChecker, I as IntelligentCompactor, f as IntelligentCompactorOptions, S as SelectiveCompactor, g as SelectiveCompactorOptions, h as SkillLoaderOptions, i as buildGoalPreamble, m as makeAutonomyPromptContributor } from '../goal-preamble-CI8lxeY1.js';
10
- import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BUunikwY.js';
11
- import { b as Response } from '../context-CNRYfhUv.js';
12
- export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-D09hMzFQ.js';
13
- export { b as AgentBudgetTier, c as AgentCapability, A as AgentDefinition, d as AgentPhase, e as DEFAULT_DISPATCH_ROLE, a as DefaultMultiAgentCoordinator, f as DispatchCandidate, D as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-51LvnXkD.js';
14
- export { h as AgentFactory, i as AgentFactoryResult, j as AgentRunnerOptions, k as BudgetExceededError, l as BudgetKind, m as BudgetLimits, r as BudgetUsage, F as FleetBus, s as FleetEvent, t as FleetHandler, u as FleetUsage, v as FleetUsageAggregator, w as SubagentBudget, x as SubagentUsageSnapshot, y as makeAgentSubagentRunner } from '../agent-subagent-runner-DukQLUcS.js';
15
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-mOxbpFcg.js';
16
- export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DU64QxQa.js';
17
- export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from '../models/index.js';
6
+ export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-vault-B7GnL6o9.js';
7
+ export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from '../permission-policy-DGOvne7i.js';
8
+ export { C as CompactorOptions, D as DefaultErrorHandler, a as DefaultRetryPolicy, E as EternalAutonomyEngine, b as EternalAutonomyOptions, c as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, d as ParallelEternalEngine, e as ParallelEternalOptions, f as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-uxVm4y4V.js';
9
+ export { A as AutoCompactionMiddleware, a as AutonomousRunner, b as AutonomousRunnerOptions, c as AutonomyPromptContributorOptions, D as DefaultSkillLoader, d as DoneCheckResult, e as DoneConditionChecker, I as IntelligentCompactor, f as IntelligentCompactorOptions, S as SelectiveCompactor, g as SelectiveCompactorOptions, h as SkillLoaderOptions, i as buildGoalPreamble, m as makeAutonomyPromptContributor } from '../goal-preamble-COpt55W8.js';
10
+ import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BPlI5sPZ.js';
11
+ import { b as Response } from '../context-hvXINa6a.js';
12
+ export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CyH2YqP4.js';
13
+ export { b as AgentBudgetTier, c as AgentCapability, A as AgentDefinition, d as AgentPhase, e as DEFAULT_DISPATCH_ROLE, a as DefaultMultiAgentCoordinator, f as DispatchCandidate, D as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-CmDmUgq2.js';
14
+ export { h as AgentFactory, i as AgentFactoryResult, j as AgentRunnerOptions, k as BudgetExceededError, l as BudgetKind, m as BudgetLimits, r as BudgetUsage, F as FleetBus, s as FleetEvent, t as FleetHandler, u as FleetUsage, v as FleetUsageAggregator, w as SubagentBudget, x as SubagentUsageSnapshot, y as makeAgentSubagentRunner } from '../agent-subagent-runner-DXWImnNV.js';
15
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-PRAbEX-9.js';
16
+ export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-BzlsjKcy.js';
17
+ export { D as DefaultModeStore, L as LLMSelector, a as LLMSelectorOptions, M as ModeLoaderOptions, l as loadProjectModes, b as loadUserModes } from '../llm-selector-Bmx4PsVM.js';
18
18
  export { AISpecBuilder, AISpecBuilderOptions, AISpecPhase, AISpecSession, AutoExecutor, AutoExecutorOptions, BottleneckTask, CollectedAnswer, CriticalPathAnalysis, DefaultTaskStore, ExecutionSummary, GeneratedTask, RunResult, SPEC_TEMPLATES, SddParallelRun, SddParallelRunOptions, SddProgress, SddTaskDecomposer, SddTaskDecomposerOptions, SpecDiff, SpecDrivenDev, SpecDrivenDevOptions, SpecIndexEntry, SpecParser, SpecStore, SpecStoreOptions, SpecVersion, SpecVersioning, TaskBatch, TaskExecutionContext, TaskExecutionResult, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskGraphIndexEntry, TaskGraphStore, TaskGraphStoreOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition, WaveResult, analyzeCriticalPath, createAutoExecutor, getTemplate, listTemplates, renderProgress, renderSpecAnalysis, renderTaskGraph, renderTaskList, templateToMarkdown } from '../sdd/index.js';
19
19
  export { DefaultHealthRegistry, InMemoryMetricsSink, MetricsServerHandle, MetricsServerOptions, NoopMetricsSink, NoopTracer, OTelTracer, OtlpMetricsExporterHandle, OtlpMetricsExporterOptions, OtlpTraceExporterHandle, OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, buildOtlpMetricsRequest, buildOtlpTracesRequest, renderPrometheus, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents } from '../observability/index.js';
20
- export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from '../mcp-servers-CXCsANdY.js';
20
+ export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from '../mcp-servers-CofNHOqn.js';
21
21
  export { D as DEFAULT_AUTONOMY_CONFIG, a as DEFAULT_CONTEXT_CONFIG, d as DEFAULT_TOOLS_CONFIG } from '../default-config-CXsDvOmP.js';
22
22
  import '../logger-B63L5bTg.js';
23
- import '../brain-Dfv4Y82E.js';
24
- import '../permission-BDv7z0mk.js';
25
- import '../wstack-paths-_lqjzErq.js';
26
- import '../config-BSU-6vah.js';
27
- import '../models-registry-B6_KfS65.js';
23
+ import '../brain-NZZqL8sn.js';
24
+ import '../permission-DhLrgA30.js';
25
+ import '../wstack-paths-DD50Omgn.js';
26
+ import '../config-DZV9VK9n.js';
28
27
  import '../secret-vault-DoISxaKO.js';
29
28
  import '../input-reader-E-ffP2ee.js';
30
- import '../retry-policy-BcmuT_V0.js';
31
- import '../compactor-DXLxLcmU.js';
32
- import '../index-DIKEcfgC.js';
33
- import '../pipeline-BqiA_UMr.js';
29
+ import '../retry-policy-B4Q-FZgE.js';
30
+ import '../compactor-C3stu664.js';
31
+ import '../index-4VVHuTZF.js';
32
+ import '../pipeline-CqF7uju2.js';
34
33
  import '../observability-D-HZN_mF.js';
35
34
  import '../goal-store-CV9Yz2X_.js';
36
35
  import '../skill-Bj6Ezqb8.js';
37
- import '../selector-C7wcdqMA.js';
36
+ import '../selector-BakeMnWR.js';
38
37
  import 'node:events';
39
- import '../mode-ARA3HrkY.js';
38
+ import '../mode-CZlO9iU1.js';
40
39
  import '../spec-TBi3Jr6T.js';
41
40
  import '../task-graph-u1q9Jkyk.js';
42
41
 
@@ -1510,39 +1510,41 @@ ${line}`;
1510
1510
  }
1511
1511
  async forget(scope, query, filePath) {
1512
1512
  const file = this.resolveFile(filePath, scope);
1513
- let existing;
1514
- try {
1515
- existing = await fsp.readFile(file, "utf8");
1516
- } catch {
1517
- return 0;
1518
- }
1519
- const needle = query.toLowerCase();
1520
- const idMatcher = /mem_\d+_\w+/;
1521
- let removed = 0;
1522
- const lines = existing.split("\n").filter((line) => {
1523
- const trimmed = line.trim();
1524
- if (!trimmed.startsWith("- ")) return true;
1525
- if (idMatcher.test(query)) {
1526
- const entryIdMatch = /mem_\d+_\w+/.exec(trimmed);
1527
- if (entryIdMatch && entryIdMatch[0] === query) {
1513
+ return withFileLock(file, async () => {
1514
+ let existing;
1515
+ try {
1516
+ existing = await fsp.readFile(file, "utf8");
1517
+ } catch {
1518
+ return 0;
1519
+ }
1520
+ const needle = query.toLowerCase();
1521
+ const idMatcher = /mem_\d+_\w+/;
1522
+ let removed = 0;
1523
+ const lines = existing.split("\n").filter((line) => {
1524
+ const trimmed = line.trim();
1525
+ if (!trimmed.startsWith("- ")) return true;
1526
+ if (idMatcher.test(query)) {
1527
+ const entryIdMatch = /mem_\d+_\w+/.exec(trimmed);
1528
+ if (entryIdMatch && entryIdMatch[0] === query) {
1529
+ removed++;
1530
+ return false;
1531
+ }
1532
+ }
1533
+ if (trimmed.toLowerCase().includes(needle)) {
1528
1534
  removed++;
1529
1535
  return false;
1530
1536
  }
1537
+ return true;
1538
+ });
1539
+ if (removed > 0) {
1540
+ if (lines.length === 0 || lines.length === 1 && !lines[0]?.trim()) {
1541
+ await atomicWrite(file, "");
1542
+ } else {
1543
+ await atomicWrite(file, lines.join("\n"));
1544
+ }
1531
1545
  }
1532
- if (trimmed.toLowerCase().includes(needle)) {
1533
- removed++;
1534
- return false;
1535
- }
1536
- return true;
1546
+ return removed;
1537
1547
  });
1538
- if (removed > 0) {
1539
- if (lines.length === 0 || lines.length === 1 && !lines[0]?.trim()) {
1540
- await atomicWrite(file, "");
1541
- } else {
1542
- await atomicWrite(file, lines.join("\n"));
1543
- }
1544
- }
1545
- return removed;
1546
1548
  }
1547
1549
  async readAll(scope, filePath) {
1548
1550
  const file = this.resolveFile(filePath, scope);
@@ -2255,12 +2257,14 @@ var DefaultConfigLoader = class {
2255
2257
  }
2256
2258
  async load(opts = {}) {
2257
2259
  let cfg = { ...BEHAVIOR_DEFAULTS };
2258
- const [global, local] = await Promise.all([
2260
+ const [global, local, inProject] = await Promise.all([
2259
2261
  this.readJson(this.paths.globalConfig),
2260
- this.readJson(this.paths.projectLocalConfig)
2262
+ this.readJson(this.paths.projectLocalConfig),
2263
+ this.readJson(this.paths.inProjectConfig)
2261
2264
  ]);
2262
2265
  cfg = deepMerge(cfg, global);
2263
2266
  cfg = deepMerge(cfg, local);
2267
+ cfg = deepMerge(cfg, inProject);
2264
2268
  for (const [key, fn] of Object.entries(ENV_MAP)) {
2265
2269
  const v = process.env[key];
2266
2270
  if (v) fn(cfg, v);
@@ -4612,6 +4616,7 @@ var DefaultRetryPolicy = class {
4612
4616
  if (err instanceof ProviderError) {
4613
4617
  if (err.status === 429) return 5;
4614
4618
  if (err.status === 529) return 3;
4619
+ if (err.status === 599) return 5;
4615
4620
  if (err.status >= 500) return 3;
4616
4621
  return 0;
4617
4622
  }
@@ -7074,6 +7079,7 @@ function resolveWstackPaths(opts) {
7074
7079
  projectTrust: path11.join(projectDir, "trust.json"),
7075
7080
  projectMeta: path11.join(projectDir, "meta.json"),
7076
7081
  projectLocalConfig: path11.join(projectDir, "config.local.json"),
7082
+ inProjectConfig: path11.join(opts.projectRoot, ".wrongstack", "config.json"),
7077
7083
  inProjectAgentsFile: path11.join(opts.projectRoot, ".wrongstack", "AGENTS.md"),
7078
7084
  inProjectSkills: path11.join(opts.projectRoot, ".wrongstack", "skills"),
7079
7085
  inProjectWorktrees: path11.join(opts.projectRoot, ".wrongstack", "worktrees"),
@@ -7098,16 +7104,20 @@ async function loadGoal(filePath) {
7098
7104
  let raw;
7099
7105
  try {
7100
7106
  raw = await fsp.readFile(filePath, "utf8");
7101
- } catch {
7102
- return null;
7107
+ } catch (err) {
7108
+ const code = err.code;
7109
+ if (code === "ENOENT") return null;
7110
+ throw err;
7103
7111
  }
7104
7112
  try {
7105
7113
  const parsed = JSON.parse(raw);
7106
7114
  if (parsed?.version !== 1 || typeof parsed.goal !== "string" || !Array.isArray(parsed.journal)) {
7115
+ console.warn(`[goal-store] Corrupt goal.json at ${filePath} \u2014 invalid schema. Consider deleting it and re-creating.`);
7107
7116
  return null;
7108
7117
  }
7109
7118
  return parsed;
7110
7119
  } catch {
7120
+ console.warn(`[goal-store] Corrupt goal.json at ${filePath} \u2014 JSON parse failed. Consider deleting it and re-creating.`);
7111
7121
  return null;
7112
7122
  }
7113
7123
  }
@@ -7161,7 +7171,7 @@ function computeTrend(history) {
7161
7171
  const recent = history.slice(-5);
7162
7172
  const deltas = [];
7163
7173
  for (let i = 1; i < recent.length; i++) {
7164
- deltas.push(recent[i].progress - recent[i - 1].progress);
7174
+ deltas.push((recent[i]?.progress ?? 0) - (recent[i - 1]?.progress ?? 0));
7165
7175
  }
7166
7176
  if (deltas.length < 2) return void 0;
7167
7177
  const avgDelta = deltas.reduce((a, b) => a + b, 0) / deltas.length;
@@ -7753,8 +7763,8 @@ ${recentJournal}` : "No prior iterations.",
7753
7763
  await saveGoal(this.goalPath, abandoned);
7754
7764
  }
7755
7765
  try {
7756
- const { unlink: unlink9 } = await import('fs/promises');
7757
- await unlink9(this.goalPath);
7766
+ const { unlink: unlink10 } = await import('fs/promises');
7767
+ await unlink10(this.goalPath);
7758
7768
  } catch {
7759
7769
  }
7760
7770
  this.opts.onEternalStop?.();
@@ -8755,6 +8765,53 @@ Working rules:
8755
8765
  "flaws"
8756
8766
  ]
8757
8767
  }
8768
+ },
8769
+ {
8770
+ config: {
8771
+ id: "refactor-planner",
8772
+ name: "Refactor Planner",
8773
+ role: "refactor-planner",
8774
+ tools: [...PLAN_TOOLS, "diff"],
8775
+ prompt: `You are the Refactor Planner agent. Your job is to analyze code
8776
+ structure and produce a concrete, phased refactoring plan with risk
8777
+ assessment, dependency ordering, and rollback strategy.
8778
+
8779
+ Scope:
8780
+ - Map module-level dependencies (import graph)
8781
+ - Identify coupling hotspots (high fan-in/out modules)
8782
+ - Assess refactoring risk by complexity and test coverage
8783
+ - Generate phased plans with checkpoint milestones
8784
+ - Produce diff-friendly task lists (one task = one concern)
8785
+
8786
+ Input format you accept:
8787
+ { "task": "plan | assess | roadmap", "target": "src/core", "constraint": "no-breaking-changes | minimal-downtime | full-rewrite", "focus": "architecture | performance | maintainability" }
8788
+
8789
+ Output: Markdown refactor plan with phases (Low Risk / Medium Risk / High Risk),
8790
+ dependency graph, rollback strategy, and exit criteria.
8791
+
8792
+ Working rules:
8793
+ - Always include rollback strategy \u2014 every refactor can fail
8794
+ - Merge tasks that take <1h into a single phase
8795
+ - Respect team constraints (reviewer availability, parallelization)
8796
+ - Never plan without analyzing the actual code first`
8797
+ },
8798
+ budget: HEAVY_BUDGET,
8799
+ capability: {
8800
+ phase: "planning",
8801
+ summary: "Refactoring planner: analyzes code structure, maps dependencies, produces risk-scored phased plans with rollback strategy.",
8802
+ keywords: [
8803
+ "refactor",
8804
+ "refactoring",
8805
+ "restructure",
8806
+ "debt",
8807
+ "technical debt",
8808
+ "clean up",
8809
+ "modularize",
8810
+ "decouple",
8811
+ "dependency graph",
8812
+ "code structure"
8813
+ ]
8814
+ }
8758
8815
  }
8759
8816
  ];
8760
8817
 
@@ -9294,6 +9351,157 @@ Working rules:
9294
9351
  "robustness"
9295
9352
  ]
9296
9353
  }
9354
+ },
9355
+ {
9356
+ config: {
9357
+ id: "security-scanner",
9358
+ name: "Security Scanner",
9359
+ role: "security-scanner",
9360
+ tools: [...TOOLS.inspect],
9361
+ prompt: `You are the Security Scanner agent. Your job is to scan code,
9362
+ configs, and dependencies for security issues from hardcoded secrets to
9363
+ supply chain risks.
9364
+
9365
+ Scope:
9366
+ - Detect hardcoded secrets: API keys, tokens, passwords, private keys
9367
+ - Find injection vectors: eval, innerHTML, SQL concat, shell injection
9368
+ - Identify insecure patterns: weak crypto, hardcoded IVs, disabled TLS
9369
+ - Scan dependencies for known CVEs (via npm/pnpm audit)
9370
+ - Flag supply chain risks: postinstall hooks, unverified scripts
9371
+
9372
+ Input format you accept:
9373
+ { "task": "scan | audit | secrets | dependencies", "paths": ["src", "config"], "depth": "quick | normal | deep" }
9374
+
9375
+ Output: Markdown security report with severity-ranked findings, injection
9376
+ vectors, dependency issues, and a remediation checklist.
9377
+
9378
+ Working rules:
9379
+ - Never scan node_modules \u2014 use npm audit instead
9380
+ - Always provide remediation steps, not just findings
9381
+ - Verify regex-based secrets before flagging (false positive risk)
9382
+ - When in doubt, flag as medium rather than ignoring potential issues`
9383
+ },
9384
+ budget: HEAVY_BUDGET,
9385
+ capability: {
9386
+ phase: "verify",
9387
+ summary: "Security scanner: detects hardcoded secrets, injection vectors, insecure patterns, and supply-chain risks with remediation.",
9388
+ keywords: [
9389
+ "security",
9390
+ "scan",
9391
+ "vulnerability",
9392
+ "secret",
9393
+ "api key",
9394
+ "hardcoded",
9395
+ "injection",
9396
+ "cve",
9397
+ "audit dependencies",
9398
+ "supply chain",
9399
+ "xss",
9400
+ "sqli",
9401
+ "shell injection",
9402
+ "sensitive data",
9403
+ "credential"
9404
+ ]
9405
+ }
9406
+ },
9407
+ {
9408
+ config: {
9409
+ id: "bug-hunter",
9410
+ name: "Bug Hunter",
9411
+ role: "bug-hunter",
9412
+ tools: [...TOOLS.inspect],
9413
+ prompt: `You are the Bug Hunter agent. Your job is to systematically scan
9414
+ source code for bugs, anti-patterns, and code smells using pattern matching
9415
+ and heuristics. Output a prioritized hit list with file:line references.
9416
+
9417
+ Scope:
9418
+ - Detect common bug patterns (uncaught errors, resource leaks, race conditions)
9419
+ - Identify anti-patterns (callback hell, God objects, circular deps)
9420
+ - Find TypeScript-specific issues (unsafe any, missing null checks, branded types)
9421
+ - Flag security-sensitive constructs (eval, innerHTML, hardcoded secrets)
9422
+ - Rank findings: critical > high > medium > low
9423
+
9424
+ Input format you accept:
9425
+ { "task": "scan | hunt | check", "paths": ["src/**/*.ts"], "focus": "bugs | patterns | security | all", "severityThreshold": "medium" }
9426
+
9427
+ Output: Markdown bug hunt report with critically/high/medium/low sections.
9428
+ Each entry: **[TYPE]** \`file:line\` \u2014 description + suggested fix
9429
+
9430
+ Working rules:
9431
+ - Never scan node_modules \u2014 it's noise
9432
+ - Always include file:line for every finding
9433
+ - If >30% of findings are false positives, note the confidence level
9434
+ - Ask director for clarification if paths are ambiguous`
9435
+ },
9436
+ budget: HEAVY_BUDGET,
9437
+ capability: {
9438
+ phase: "verify",
9439
+ summary: "Bug hunter: scans source code for bugs, anti-patterns, and code smells, producing a file:line-ranked hit list with fixes.",
9440
+ keywords: [
9441
+ "bug",
9442
+ "hunt",
9443
+ "scan",
9444
+ "code smell",
9445
+ "anti-pattern",
9446
+ "race condition",
9447
+ "memory leak",
9448
+ "null deref",
9449
+ "type safety",
9450
+ "unhandled error",
9451
+ "find bugs",
9452
+ "audit code",
9453
+ "code quality"
9454
+ ]
9455
+ }
9456
+ },
9457
+ {
9458
+ config: {
9459
+ id: "audit-log",
9460
+ name: "Audit Log",
9461
+ role: "audit-log",
9462
+ tools: [...TOOLS.inspect],
9463
+ prompt: `You are the Audit Log agent. Your job is to analyze structured JSONL
9464
+ session logs and produce actionable markdown reports.
9465
+
9466
+ Scope:
9467
+ - Parse session logs (iteration counts, tool calls, errors, usage)
9468
+ - Detect repeated failure patterns across multiple runs
9469
+ - Identify tool usage anomalies (over-use, failures, unexpected chains)
9470
+ - Track token consumption trends
9471
+ - Generate structured audit reports with severity ratings
9472
+
9473
+ Input format you accept:
9474
+ { "task": "analyze | report | trends", "sessionPath": "<path>", "focus": "errors | tools | usage | all" }
9475
+
9476
+ Output: Markdown audit report with Summary, Top Errors, Tool Usage table,
9477
+ Anomalies, and Cost Trend sections.
9478
+
9479
+ Working rules:
9480
+ - Never fabricate numbers \u2014 read the actual logs first
9481
+ - Always include file:line references for errors
9482
+ - If sessionPath is missing, ask the director to provide it
9483
+ - Report confidence level: high (>90% accuracy), medium, low`
9484
+ },
9485
+ budget: MEDIUM_BUDGET,
9486
+ capability: {
9487
+ phase: "verify",
9488
+ summary: "Audit log analyzer: parses session JSONL, detects failure patterns, tool anomalies, and cost trends with structured reports.",
9489
+ keywords: [
9490
+ "audit",
9491
+ "log",
9492
+ "logs",
9493
+ "session",
9494
+ "trace",
9495
+ "analyze logs",
9496
+ "error patterns",
9497
+ "cost analysis",
9498
+ "tool usage",
9499
+ "token usage",
9500
+ "post-mortem",
9501
+ "trend",
9502
+ "anomaly"
9503
+ ]
9504
+ }
9297
9505
  }
9298
9506
  ];
9299
9507