cognitive-core 0.2.1 → 0.2.3
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/atlas.d.ts +10 -0
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +65 -0
- package/dist/atlas.js.map +1 -1
- package/dist/bin/cognitive-core.js +0 -0
- package/dist/memory/curated-loader.d.ts +21 -4
- package/dist/memory/curated-loader.d.ts.map +1 -1
- package/dist/memory/curated-loader.js +53 -16
- package/dist/memory/curated-loader.js.map +1 -1
- package/dist/memory/index.d.ts +2 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +3 -1
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/playbook.d.ts +6 -0
- package/dist/memory/playbook.d.ts.map +1 -1
- package/dist/memory/playbook.js +15 -0
- package/dist/memory/playbook.js.map +1 -1
- package/dist/memory/source-resolver.d.ts +120 -0
- package/dist/memory/source-resolver.d.ts.map +1 -0
- package/dist/memory/source-resolver.js +300 -0
- package/dist/memory/source-resolver.js.map +1 -0
- package/dist/types/config.d.ts +141 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +40 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/workspace/types.d.ts +12 -54
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/types.js.map +1 -1
- package/package.json +3 -3
- package/playbooks/compound-engineering/adversarial-review.json +51 -0
- package/playbooks/compound-engineering/agent-native-architecture.json +59 -0
- package/playbooks/compound-engineering/agent-native-review.json +54 -0
- package/playbooks/compound-engineering/api-contract-review.json +52 -0
- package/playbooks/compound-engineering/brainstorm-requirements.json +55 -0
- package/playbooks/compound-engineering/bug-reproduction.json +62 -0
- package/playbooks/compound-engineering/confidence-calibration.json +49 -0
- package/playbooks/compound-engineering/correctness-review.json +49 -0
- package/playbooks/compound-engineering/data-migration-safety.json +59 -0
- package/playbooks/compound-engineering/deployment-verification.json +63 -0
- package/playbooks/compound-engineering/error-recovery-patterns.json +53 -0
- package/playbooks/compound-engineering/implementation-planning.json +64 -0
- package/playbooks/compound-engineering/issue-pattern-analysis.json +53 -0
- package/playbooks/compound-engineering/knowledge-compounding.json +63 -0
- package/playbooks/compound-engineering/learnings-research.json +54 -0
- package/playbooks/compound-engineering/maintainability-review.json +49 -0
- package/playbooks/compound-engineering/performance-review.json +54 -0
- package/playbooks/compound-engineering/plan-adversarial-review.json +56 -0
- package/playbooks/compound-engineering/plan-feasibility-review.json +56 -0
- package/playbooks/compound-engineering/project-standards-review.json +52 -0
- package/playbooks/compound-engineering/reliability-review.json +53 -0
- package/playbooks/compound-engineering/review-orchestration.json +64 -0
- package/playbooks/compound-engineering/security-review.json +54 -0
- package/playbooks/compound-engineering/systematic-execution.json +64 -0
- package/playbooks/compound-engineering/testing-review.json +50 -0
- package/src/atlas.ts +96 -0
- package/src/memory/curated-loader.ts +69 -16
- package/src/memory/index.ts +16 -0
- package/src/memory/playbook.ts +19 -0
- package/src/memory/source-resolver.ts +422 -0
- package/src/types/config.ts +46 -0
- package/src/types/index.ts +4 -0
- package/src/workspace/types.ts +22 -78
- package/tests/integration/curated-sources-e2e.test.ts +502 -0
- package/tests/memory/compound-engineering-seed.test.ts +338 -0
- package/tests/memory/curated-loader-extended.test.ts +225 -0
- package/tests/memory/playbook-quality-validation.test.ts +430 -0
- package/tests/memory/source-resolver.test.ts +700 -0
- package/.claude/settings.local.json +0 -11
- package/dist/learning/llm-extractor.d.ts +0 -88
- package/dist/learning/llm-extractor.d.ts.map +0 -1
- package/dist/learning/llm-extractor.js +0 -372
- package/dist/learning/llm-extractor.js.map +0 -1
- package/dist/learning/loop-coordinator.d.ts +0 -61
- package/dist/learning/loop-coordinator.d.ts.map +0 -1
- package/dist/learning/loop-coordinator.js +0 -96
- package/dist/learning/loop-coordinator.js.map +0 -1
- package/dist/learning/pipeline.d.ts +0 -116
- package/dist/learning/pipeline.d.ts.map +0 -1
- package/dist/learning/pipeline.js +0 -288
- package/dist/learning/pipeline.js.map +0 -1
- package/references/agent-workspace/CLAUDE.md +0 -74
- package/references/agent-workspace/README.md +0 -587
- package/references/agent-workspace/media/banner.png +0 -0
- package/references/agent-workspace/package-lock.json +0 -2061
- package/references/agent-workspace/package.json +0 -54
- package/references/agent-workspace/src/handle.ts +0 -122
- package/references/agent-workspace/src/index.ts +0 -32
- package/references/agent-workspace/src/manager.ts +0 -102
- package/references/agent-workspace/src/readers/json.ts +0 -71
- package/references/agent-workspace/src/readers/markdown.ts +0 -37
- package/references/agent-workspace/src/readers/raw.ts +0 -27
- package/references/agent-workspace/src/types.ts +0 -68
- package/references/agent-workspace/src/validation.ts +0 -93
- package/references/agent-workspace/src/writers/json.ts +0 -17
- package/references/agent-workspace/src/writers/markdown.ts +0 -27
- package/references/agent-workspace/src/writers/raw.ts +0 -22
- package/references/agent-workspace/tests/errors.test.ts +0 -652
- package/references/agent-workspace/tests/handle.test.ts +0 -144
- package/references/agent-workspace/tests/manager.test.ts +0 -124
- package/references/agent-workspace/tests/readers.test.ts +0 -205
- package/references/agent-workspace/tests/validation.test.ts +0 -196
- package/references/agent-workspace/tests/writers.test.ts +0 -108
- package/references/agent-workspace/tsconfig.json +0 -20
- package/references/agent-workspace/tsup.config.ts +0 -9
- package/references/minimem/.claude/settings.json +0 -7
- package/references/minimem/.sudocode/issues.jsonl +0 -18
- package/references/minimem/.sudocode/specs.jsonl +0 -1
- package/references/minimem/CLAUDE.md +0 -310
- package/references/minimem/README.md +0 -556
- package/references/minimem/claude-plugin/.claude-plugin/plugin.json +0 -10
- package/references/minimem/claude-plugin/.mcp.json +0 -7
- package/references/minimem/claude-plugin/README.md +0 -158
- package/references/minimem/claude-plugin/commands/recall.md +0 -47
- package/references/minimem/claude-plugin/commands/remember.md +0 -41
- package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +0 -272
- package/references/minimem/claude-plugin/hooks/hooks.json +0 -27
- package/references/minimem/claude-plugin/hooks/session-end.sh +0 -86
- package/references/minimem/claude-plugin/hooks/session-start.sh +0 -85
- package/references/minimem/claude-plugin/skills/memory/SKILL.md +0 -108
- package/references/minimem/package-lock.json +0 -5373
- package/references/minimem/package.json +0 -60
- package/references/minimem/scripts/postbuild.js +0 -35
- package/references/minimem/src/__tests__/edge-cases.test.ts +0 -371
- package/references/minimem/src/__tests__/errors.test.ts +0 -265
- package/references/minimem/src/__tests__/helpers.ts +0 -199
- package/references/minimem/src/__tests__/internal.test.ts +0 -407
- package/references/minimem/src/__tests__/knowledge.test.ts +0 -287
- package/references/minimem/src/__tests__/minimem.integration.test.ts +0 -1127
- package/references/minimem/src/__tests__/session.test.ts +0 -190
- package/references/minimem/src/cli/__tests__/commands.test.ts +0 -759
- package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +0 -141
- package/references/minimem/src/cli/commands/append.ts +0 -76
- package/references/minimem/src/cli/commands/config.ts +0 -262
- package/references/minimem/src/cli/commands/conflicts.ts +0 -413
- package/references/minimem/src/cli/commands/daemon.ts +0 -169
- package/references/minimem/src/cli/commands/index.ts +0 -12
- package/references/minimem/src/cli/commands/init.ts +0 -88
- package/references/minimem/src/cli/commands/mcp.ts +0 -177
- package/references/minimem/src/cli/commands/push-pull.ts +0 -213
- package/references/minimem/src/cli/commands/search.ts +0 -158
- package/references/minimem/src/cli/commands/status.ts +0 -84
- package/references/minimem/src/cli/commands/sync-init.ts +0 -290
- package/references/minimem/src/cli/commands/sync.ts +0 -70
- package/references/minimem/src/cli/commands/upsert.ts +0 -197
- package/references/minimem/src/cli/config.ts +0 -584
- package/references/minimem/src/cli/index.ts +0 -264
- package/references/minimem/src/cli/shared.ts +0 -161
- package/references/minimem/src/cli/sync/__tests__/central.test.ts +0 -152
- package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +0 -209
- package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +0 -118
- package/references/minimem/src/cli/sync/__tests__/detection.test.ts +0 -207
- package/references/minimem/src/cli/sync/__tests__/integration.test.ts +0 -476
- package/references/minimem/src/cli/sync/__tests__/registry.test.ts +0 -363
- package/references/minimem/src/cli/sync/__tests__/state.test.ts +0 -255
- package/references/minimem/src/cli/sync/__tests__/validation.test.ts +0 -193
- package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +0 -178
- package/references/minimem/src/cli/sync/central.ts +0 -292
- package/references/minimem/src/cli/sync/conflicts.ts +0 -204
- package/references/minimem/src/cli/sync/daemon.ts +0 -407
- package/references/minimem/src/cli/sync/detection.ts +0 -138
- package/references/minimem/src/cli/sync/index.ts +0 -107
- package/references/minimem/src/cli/sync/operations.ts +0 -373
- package/references/minimem/src/cli/sync/registry.ts +0 -279
- package/references/minimem/src/cli/sync/state.ts +0 -355
- package/references/minimem/src/cli/sync/validation.ts +0 -206
- package/references/minimem/src/cli/sync/watcher.ts +0 -234
- package/references/minimem/src/cli/version.ts +0 -34
- package/references/minimem/src/core/index.ts +0 -9
- package/references/minimem/src/core/indexer.ts +0 -628
- package/references/minimem/src/core/searcher.ts +0 -221
- package/references/minimem/src/db/schema.ts +0 -183
- package/references/minimem/src/db/sqlite-vec.ts +0 -24
- package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +0 -431
- package/references/minimem/src/embeddings/batch-gemini.ts +0 -392
- package/references/minimem/src/embeddings/batch-openai.ts +0 -409
- package/references/minimem/src/embeddings/embeddings.ts +0 -434
- package/references/minimem/src/index.ts +0 -109
- package/references/minimem/src/internal.ts +0 -299
- package/references/minimem/src/minimem.ts +0 -1276
- package/references/minimem/src/search/__tests__/hybrid.test.ts +0 -247
- package/references/minimem/src/search/graph.ts +0 -234
- package/references/minimem/src/search/hybrid.ts +0 -151
- package/references/minimem/src/search/search.ts +0 -256
- package/references/minimem/src/server/__tests__/mcp.test.ts +0 -341
- package/references/minimem/src/server/__tests__/tools.test.ts +0 -364
- package/references/minimem/src/server/mcp.ts +0 -326
- package/references/minimem/src/server/tools.ts +0 -720
- package/references/minimem/src/session.ts +0 -460
- package/references/minimem/tsconfig.json +0 -19
- package/references/minimem/tsup.config.ts +0 -26
- package/references/minimem/vitest.config.ts +0 -24
- package/references/sessionlog/.husky/pre-commit +0 -1
- package/references/sessionlog/.lintstagedrc.json +0 -4
- package/references/sessionlog/.prettierignore +0 -4
- package/references/sessionlog/.prettierrc.json +0 -11
- package/references/sessionlog/LICENSE +0 -21
- package/references/sessionlog/README.md +0 -453
- package/references/sessionlog/eslint.config.js +0 -58
- package/references/sessionlog/package-lock.json +0 -3672
- package/references/sessionlog/package.json +0 -65
- package/references/sessionlog/src/__tests__/agent-hooks.test.ts +0 -570
- package/references/sessionlog/src/__tests__/agent-registry.test.ts +0 -127
- package/references/sessionlog/src/__tests__/claude-code-hooks.test.ts +0 -225
- package/references/sessionlog/src/__tests__/claude-generator.test.ts +0 -46
- package/references/sessionlog/src/__tests__/commit-msg.test.ts +0 -86
- package/references/sessionlog/src/__tests__/cursor-agent.test.ts +0 -224
- package/references/sessionlog/src/__tests__/e2e-live.test.ts +0 -890
- package/references/sessionlog/src/__tests__/event-log.test.ts +0 -183
- package/references/sessionlog/src/__tests__/flush-sentinel.test.ts +0 -105
- package/references/sessionlog/src/__tests__/gemini-agent.test.ts +0 -375
- package/references/sessionlog/src/__tests__/git-hooks.test.ts +0 -78
- package/references/sessionlog/src/__tests__/hook-managers.test.ts +0 -121
- package/references/sessionlog/src/__tests__/lifecycle-tasks.test.ts +0 -759
- package/references/sessionlog/src/__tests__/opencode-agent.test.ts +0 -338
- package/references/sessionlog/src/__tests__/redaction.test.ts +0 -136
- package/references/sessionlog/src/__tests__/session-repo.test.ts +0 -353
- package/references/sessionlog/src/__tests__/session-store.test.ts +0 -166
- package/references/sessionlog/src/__tests__/setup-ccweb.test.ts +0 -466
- package/references/sessionlog/src/__tests__/skill-live.test.ts +0 -461
- package/references/sessionlog/src/__tests__/summarize.test.ts +0 -348
- package/references/sessionlog/src/__tests__/task-plan-e2e.test.ts +0 -610
- package/references/sessionlog/src/__tests__/task-plan-live.test.ts +0 -632
- package/references/sessionlog/src/__tests__/transcript-timestamp.test.ts +0 -121
- package/references/sessionlog/src/__tests__/types.test.ts +0 -166
- package/references/sessionlog/src/__tests__/utils.test.ts +0 -333
- package/references/sessionlog/src/__tests__/validation.test.ts +0 -103
- package/references/sessionlog/src/__tests__/worktree.test.ts +0 -57
- package/references/sessionlog/src/agent/agents/claude-code.ts +0 -1089
- package/references/sessionlog/src/agent/agents/cursor.ts +0 -361
- package/references/sessionlog/src/agent/agents/gemini-cli.ts +0 -632
- package/references/sessionlog/src/agent/agents/opencode.ts +0 -540
- package/references/sessionlog/src/agent/registry.ts +0 -143
- package/references/sessionlog/src/agent/session-types.ts +0 -113
- package/references/sessionlog/src/agent/types.ts +0 -220
- package/references/sessionlog/src/cli.ts +0 -597
- package/references/sessionlog/src/commands/clean.ts +0 -133
- package/references/sessionlog/src/commands/disable.ts +0 -84
- package/references/sessionlog/src/commands/doctor.ts +0 -145
- package/references/sessionlog/src/commands/enable.ts +0 -202
- package/references/sessionlog/src/commands/explain.ts +0 -261
- package/references/sessionlog/src/commands/reset.ts +0 -105
- package/references/sessionlog/src/commands/resume.ts +0 -180
- package/references/sessionlog/src/commands/rewind.ts +0 -195
- package/references/sessionlog/src/commands/setup-ccweb.ts +0 -275
- package/references/sessionlog/src/commands/status.ts +0 -172
- package/references/sessionlog/src/config.ts +0 -165
- package/references/sessionlog/src/events/event-log.ts +0 -126
- package/references/sessionlog/src/git-operations.ts +0 -558
- package/references/sessionlog/src/hooks/git-hooks.ts +0 -165
- package/references/sessionlog/src/hooks/lifecycle.ts +0 -391
- package/references/sessionlog/src/index.ts +0 -650
- package/references/sessionlog/src/security/redaction.ts +0 -283
- package/references/sessionlog/src/session/state-machine.ts +0 -452
- package/references/sessionlog/src/store/checkpoint-store.ts +0 -509
- package/references/sessionlog/src/store/native-store.ts +0 -173
- package/references/sessionlog/src/store/provider-types.ts +0 -99
- package/references/sessionlog/src/store/session-store.ts +0 -266
- package/references/sessionlog/src/strategy/attribution.ts +0 -296
- package/references/sessionlog/src/strategy/common.ts +0 -207
- package/references/sessionlog/src/strategy/content-overlap.ts +0 -228
- package/references/sessionlog/src/strategy/manual-commit.ts +0 -988
- package/references/sessionlog/src/strategy/types.ts +0 -279
- package/references/sessionlog/src/summarize/claude-generator.ts +0 -115
- package/references/sessionlog/src/summarize/summarize.ts +0 -432
- package/references/sessionlog/src/types.ts +0 -508
- package/references/sessionlog/src/utils/chunk-files.ts +0 -49
- package/references/sessionlog/src/utils/commit-message.ts +0 -65
- package/references/sessionlog/src/utils/detect-agent.ts +0 -36
- package/references/sessionlog/src/utils/hook-managers.ts +0 -125
- package/references/sessionlog/src/utils/ide-tags.ts +0 -32
- package/references/sessionlog/src/utils/paths.ts +0 -79
- package/references/sessionlog/src/utils/preview-rewind.ts +0 -80
- package/references/sessionlog/src/utils/rewind-conflict.ts +0 -121
- package/references/sessionlog/src/utils/shadow-branch.ts +0 -109
- package/references/sessionlog/src/utils/string-utils.ts +0 -46
- package/references/sessionlog/src/utils/todo-extract.ts +0 -188
- package/references/sessionlog/src/utils/trailers.ts +0 -187
- package/references/sessionlog/src/utils/transcript-parse.ts +0 -177
- package/references/sessionlog/src/utils/transcript-timestamp.ts +0 -59
- package/references/sessionlog/src/utils/tree-ops.ts +0 -219
- package/references/sessionlog/src/utils/tty.ts +0 -72
- package/references/sessionlog/src/utils/validation.ts +0 -65
- package/references/sessionlog/src/utils/worktree.ts +0 -58
- package/references/sessionlog/src/wire-types.ts +0 -59
- package/references/sessionlog/templates/setup-env.sh +0 -153
- package/references/sessionlog/tsconfig.json +0 -18
- package/references/sessionlog/vitest.config.ts +0 -12
- package/references/skill-tree/.claude/settings.json +0 -6
- package/references/skill-tree/.sudocode/issues.jsonl +0 -19
- package/references/skill-tree/.sudocode/specs.jsonl +0 -3
- package/references/skill-tree/CLAUDE.md +0 -126
- package/references/skill-tree/README.md +0 -372
- package/references/skill-tree/docs/GAPS_v1.md +0 -221
- package/references/skill-tree/docs/INTEGRATION_PLAN.md +0 -467
- package/references/skill-tree/docs/TODOS.md +0 -91
- package/references/skill-tree/docs/anthropic_skill_guide.md +0 -1364
- package/references/skill-tree/docs/design/federated-skill-trees.md +0 -524
- package/references/skill-tree/docs/design/multi-agent-sync.md +0 -759
- package/references/skill-tree/docs/scraper/BRAINSTORM.md +0 -583
- package/references/skill-tree/docs/scraper/POC_PLAN.md +0 -420
- package/references/skill-tree/docs/scraper/README.md +0 -170
- package/references/skill-tree/examples/basic-usage.ts +0 -164
- package/references/skill-tree/package-lock.json +0 -1852
- package/references/skill-tree/package.json +0 -66
- package/references/skill-tree/scraper/README.md +0 -123
- package/references/skill-tree/scraper/docs/DESIGN.md +0 -683
- package/references/skill-tree/scraper/docs/PLAN.md +0 -336
- package/references/skill-tree/scraper/drizzle.config.ts +0 -10
- package/references/skill-tree/scraper/package-lock.json +0 -6329
- package/references/skill-tree/scraper/package.json +0 -68
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +0 -7
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +0 -7
- package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +0 -27
- package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +0 -21
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +0 -54
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +0 -24
- package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +0 -93
- package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +0 -22
- package/references/skill-tree/scraper/tsup.config.ts +0 -14
- package/references/skill-tree/scraper/vitest.config.ts +0 -17
- package/references/skill-tree/scripts/convert-to-vitest.ts +0 -166
- package/references/skill-tree/skills/skill-writer/SKILL.md +0 -339
- package/references/skill-tree/skills/skill-writer/references/examples.md +0 -326
- package/references/skill-tree/skills/skill-writer/references/patterns.md +0 -210
- package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +0 -123
- package/references/skill-tree/test/run-all.ts +0 -106
- package/references/skill-tree/test/utils.ts +0 -128
- package/references/skill-tree/vitest.config.ts +0 -16
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { Trajectory, LearningConfig } from '../types/index.js';
|
|
2
|
-
import type { TrajectoryWithAnalysis } from '../types/trajectory-source.js';
|
|
3
|
-
import type { MemorySystem } from '../memory/system.js';
|
|
4
|
-
import { type AnalysisResult } from './analyzer.js';
|
|
5
|
-
import type { SqlitePersistence } from '../persistence/index.js';
|
|
6
|
-
import type { AgenticTaskRunner } from '../workspace/runner.js';
|
|
7
|
-
/**
|
|
8
|
-
* Result of processing a single trajectory
|
|
9
|
-
*/
|
|
10
|
-
export interface ProcessResult {
|
|
11
|
-
trajectoryId: string;
|
|
12
|
-
stored: boolean;
|
|
13
|
-
analysis: AnalysisResult;
|
|
14
|
-
abstractable: boolean;
|
|
15
|
-
playbookExtracted: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Result of batch learning
|
|
19
|
-
*/
|
|
20
|
-
export interface BatchResult {
|
|
21
|
-
trajectoriesProcessed: number;
|
|
22
|
-
playbooksExtracted: number;
|
|
23
|
-
experiencesPruned: number;
|
|
24
|
-
experiencesCompressed: {
|
|
25
|
-
promoted: number;
|
|
26
|
-
demoted: number;
|
|
27
|
-
evicted: number;
|
|
28
|
-
};
|
|
29
|
-
experiencesClustered: number;
|
|
30
|
-
successRate: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Learning Pipeline
|
|
34
|
-
* Orchestrates trajectory analysis, playbook extraction, and memory updates
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* Feature flags for optional ruvector-inspired subsystems in the batch pipeline.
|
|
38
|
-
*/
|
|
39
|
-
export interface PipelineFeatureOptions {
|
|
40
|
-
/** Enable temporal compression (Hot/Warm/Cold/Evict) in batch pipeline (default: true) */
|
|
41
|
-
enableTemporalCompression?: boolean;
|
|
42
|
-
/** Enable experience clustering via ReasoningBank in batch pipeline (default: true) */
|
|
43
|
-
enableReasoningBank?: boolean;
|
|
44
|
-
}
|
|
45
|
-
export declare class LearningPipeline {
|
|
46
|
-
private analyzer;
|
|
47
|
-
private playbookExtractor;
|
|
48
|
-
private temporalCompressor;
|
|
49
|
-
private reasoningBank;
|
|
50
|
-
private memory;
|
|
51
|
-
private config;
|
|
52
|
-
private taskRunner;
|
|
53
|
-
private accumulated;
|
|
54
|
-
private accumulatedAnalyses;
|
|
55
|
-
private lastBatchTime;
|
|
56
|
-
constructor(memory: MemorySystem, config?: Partial<LearningConfig>, featureOptions?: PipelineFeatureOptions, persistence?: SqlitePersistence);
|
|
57
|
-
/**
|
|
58
|
-
* Load persisted state for internal components (TemporalCompressor, ReasoningBank).
|
|
59
|
-
* Call after persistence is initialized.
|
|
60
|
-
*/
|
|
61
|
-
loadPersistedState(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Set the agentic task runner for workspace-based analysis.
|
|
64
|
-
* When set, analysis tasks are delegated to templates (with heuristic fallback).
|
|
65
|
-
*/
|
|
66
|
-
setTaskRunner(runner: AgenticTaskRunner): void;
|
|
67
|
-
/**
|
|
68
|
-
* Process a single trajectory.
|
|
69
|
-
* Set skipStore to true if the caller already stored the experience
|
|
70
|
-
* (e.g., via InstantLoop / LoopCoordinator).
|
|
71
|
-
*/
|
|
72
|
-
processTrajectory(trajectory: Trajectory, options?: {
|
|
73
|
-
skipStore?: boolean;
|
|
74
|
-
}): Promise<ProcessResult>;
|
|
75
|
-
/**
|
|
76
|
-
* Run trajectory analysis via the workspace template.
|
|
77
|
-
* The template's assessComplexity() routes simple cases to heuristicFallback()
|
|
78
|
-
* (which calls the existing TrajectoryAnalyzer), so this is safe for all inputs.
|
|
79
|
-
*/
|
|
80
|
-
private analyzeWithTemplate;
|
|
81
|
-
/**
|
|
82
|
-
* Check if batch learning should run
|
|
83
|
-
*/
|
|
84
|
-
shouldRunBatch(): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Run batch learning on accumulated trajectories
|
|
87
|
-
*/
|
|
88
|
-
runBatchLearning(): Promise<BatchResult>;
|
|
89
|
-
/**
|
|
90
|
-
* Run playbook extraction via the workspace template.
|
|
91
|
-
* Falls back to heuristic extractor on failure.
|
|
92
|
-
*/
|
|
93
|
-
private extractPlaybooks;
|
|
94
|
-
/**
|
|
95
|
-
* Get accumulated trajectory count
|
|
96
|
-
*/
|
|
97
|
-
getAccumulatedCount(): number;
|
|
98
|
-
/**
|
|
99
|
-
* Get accumulated trajectories with their analyses.
|
|
100
|
-
* Read-only view — does not clear the accumulator.
|
|
101
|
-
*/
|
|
102
|
-
getAccumulated(): TrajectoryWithAnalysis[];
|
|
103
|
-
/**
|
|
104
|
-
* Clear accumulated trajectories
|
|
105
|
-
*/
|
|
106
|
-
clearAccumulated(): void;
|
|
107
|
-
/**
|
|
108
|
-
* Update configuration
|
|
109
|
-
*/
|
|
110
|
-
updateConfig(config: Partial<LearningConfig>): void;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Create a learning pipeline
|
|
114
|
-
*/
|
|
115
|
-
export declare function createLearningPipeline(memory: MemorySystem, config?: Partial<LearningConfig>, featureOptions?: PipelineFeatureOptions, persistence?: SqlitePersistence): LearningPipeline;
|
|
116
|
-
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/learning/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AA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,EAChC,cAAc,CAAC,EAAE,sBAAsB,EACvC,WAAW,CAAC,EAAE,iBAAiB;IA2BjC;;;OAGG;IACH,kBAAkB,IAAI,IAAI;IAK1B;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAI9C;;;;OAIG;IACG,iBAAiB,CACrB,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAChC,OAAO,CAAC,aAAa,CAAC;IA2BzB;;;;OAIG;YACW,mBAAmB;IAiBjC;;OAEG;IACH,cAAc,IAAI,OAAO;IA6BzB;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,WAAW,CAAC;IAoH9C;;;OAGG;YACW,gBAAgB;IA0B9B;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAI7B;;;OAGG;IACH,cAAc,IAAI,sBAAsB,EAAE;IAO1C;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAKxB;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;CAMpD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAChC,cAAc,CAAC,EAAE,sBAAsB,EACvC,WAAW,CAAC,EAAE,iBAAiB,GAC9B,gBAAgB,CAElB"}
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { createAnalyzer, } from './analyzer.js';
|
|
2
|
-
import { createPlaybookExtractor, } from './playbook-extractor.js';
|
|
3
|
-
import { TemporalCompressor } from '../memory/temporal-compressor.js';
|
|
4
|
-
import { ReasoningBank } from '../memory/reasoning-bank.js';
|
|
5
|
-
import { trajectoryAnalysisTemplate } from '../workspace/templates/trajectory-analysis.js';
|
|
6
|
-
import { playbookExtractionTemplate } from '../workspace/templates/playbook-extraction.js';
|
|
7
|
-
export class LearningPipeline {
|
|
8
|
-
analyzer;
|
|
9
|
-
playbookExtractor;
|
|
10
|
-
temporalCompressor;
|
|
11
|
-
reasoningBank;
|
|
12
|
-
memory;
|
|
13
|
-
config;
|
|
14
|
-
// Optional agentic task runner for workspace-based analysis
|
|
15
|
-
taskRunner = null;
|
|
16
|
-
// Accumulated trajectories for batch learning
|
|
17
|
-
accumulated = [];
|
|
18
|
-
accumulatedAnalyses = [];
|
|
19
|
-
lastBatchTime = null;
|
|
20
|
-
constructor(memory, config, featureOptions, persistence) {
|
|
21
|
-
this.memory = memory;
|
|
22
|
-
this.config = {
|
|
23
|
-
creditStrategy: config?.creditStrategy ?? 'simple',
|
|
24
|
-
patternExtractor: config?.patternExtractor ?? 'llm',
|
|
25
|
-
minTrajectories: config?.minTrajectories ?? 10,
|
|
26
|
-
minHoursSinceLast: config?.minHoursSinceLast,
|
|
27
|
-
minSuccessRate: config?.minSuccessRate,
|
|
28
|
-
deduplicationThreshold: config?.deduplicationThreshold ?? 0.9,
|
|
29
|
-
maxExperiences: config?.maxExperiences ?? 1000,
|
|
30
|
-
};
|
|
31
|
-
this.analyzer = createAnalyzer(this.config.creditStrategy);
|
|
32
|
-
this.temporalCompressor = (featureOptions?.enableTemporalCompression ?? true)
|
|
33
|
-
? new TemporalCompressor(undefined, persistence)
|
|
34
|
-
: null;
|
|
35
|
-
this.reasoningBank = (featureOptions?.enableReasoningBank ?? true)
|
|
36
|
-
? new ReasoningBank(undefined, persistence)
|
|
37
|
-
: null;
|
|
38
|
-
this.playbookExtractor = createPlaybookExtractor({
|
|
39
|
-
minTrajectories: this.config.minTrajectories,
|
|
40
|
-
mergeThreshold: this.config.deduplicationThreshold,
|
|
41
|
-
minSuccessRate: this.config.minSuccessRate ?? 0.6,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Load persisted state for internal components (TemporalCompressor, ReasoningBank).
|
|
46
|
-
* Call after persistence is initialized.
|
|
47
|
-
*/
|
|
48
|
-
loadPersistedState() {
|
|
49
|
-
this.temporalCompressor?.loadPersistedState();
|
|
50
|
-
this.reasoningBank?.loadPersistedState();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Set the agentic task runner for workspace-based analysis.
|
|
54
|
-
* When set, analysis tasks are delegated to templates (with heuristic fallback).
|
|
55
|
-
*/
|
|
56
|
-
setTaskRunner(runner) {
|
|
57
|
-
this.taskRunner = runner;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Process a single trajectory.
|
|
61
|
-
* Set skipStore to true if the caller already stored the experience
|
|
62
|
-
* (e.g., via InstantLoop / LoopCoordinator).
|
|
63
|
-
*/
|
|
64
|
-
async processTrajectory(trajectory, options) {
|
|
65
|
-
// Store in experience memory (unless already stored by instant loop)
|
|
66
|
-
if (!options?.skipStore) {
|
|
67
|
-
await this.memory.storeTrajectory(trajectory);
|
|
68
|
-
}
|
|
69
|
-
// Analyze: workspace-based when runner available, heuristic otherwise
|
|
70
|
-
let analysis;
|
|
71
|
-
if (this.taskRunner) {
|
|
72
|
-
analysis = await this.analyzeWithTemplate(trajectory);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
analysis = await this.analyzer.analyze(trajectory);
|
|
76
|
-
}
|
|
77
|
-
// Accumulate for batch learning
|
|
78
|
-
this.accumulated.push(trajectory);
|
|
79
|
-
this.accumulatedAnalyses.push(analysis);
|
|
80
|
-
return {
|
|
81
|
-
trajectoryId: trajectory.id,
|
|
82
|
-
stored: true,
|
|
83
|
-
analysis,
|
|
84
|
-
abstractable: analysis.abstractable,
|
|
85
|
-
playbookExtracted: false, // Playbooks are extracted in batch
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Run trajectory analysis via the workspace template.
|
|
90
|
-
* The template's assessComplexity() routes simple cases to heuristicFallback()
|
|
91
|
-
* (which calls the existing TrajectoryAnalyzer), so this is safe for all inputs.
|
|
92
|
-
*/
|
|
93
|
-
async analyzeWithTemplate(trajectory) {
|
|
94
|
-
try {
|
|
95
|
-
const result = await this.taskRunner.run(trajectoryAnalysisTemplate, {
|
|
96
|
-
trajectory,
|
|
97
|
-
creditStrategy: this.config.creditStrategy,
|
|
98
|
-
});
|
|
99
|
-
return result.output;
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
// If workspace-based analysis fails, fall back to heuristic
|
|
103
|
-
console.error('Workspace-based trajectory analysis failed, falling back to heuristic:', error instanceof Error ? error.message : error);
|
|
104
|
-
return this.analyzer.analyze(trajectory);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Check if batch learning should run
|
|
109
|
-
*/
|
|
110
|
-
shouldRunBatch() {
|
|
111
|
-
// Check minimum trajectories
|
|
112
|
-
if (this.accumulated.length < this.config.minTrajectories) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
// Check time since last batch
|
|
116
|
-
if (this.config.minHoursSinceLast && this.lastBatchTime) {
|
|
117
|
-
const hoursSinceLast = (Date.now() - this.lastBatchTime.getTime()) / (1000 * 60 * 60);
|
|
118
|
-
if (hoursSinceLast < this.config.minHoursSinceLast) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Check success rate
|
|
123
|
-
if (this.config.minSuccessRate) {
|
|
124
|
-
const successCount = this.accumulatedAnalyses.filter((a) => a.success).length;
|
|
125
|
-
const successRate = successCount / this.accumulated.length;
|
|
126
|
-
if (successRate < this.config.minSuccessRate) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Run batch learning on accumulated trajectories
|
|
134
|
-
*/
|
|
135
|
-
async runBatchLearning() {
|
|
136
|
-
if (this.accumulated.length === 0) {
|
|
137
|
-
return {
|
|
138
|
-
trajectoriesProcessed: 0,
|
|
139
|
-
playbooksExtracted: 0,
|
|
140
|
-
experiencesPruned: 0,
|
|
141
|
-
experiencesCompressed: { promoted: 0, demoted: 0, evicted: 0 },
|
|
142
|
-
experiencesClustered: 0,
|
|
143
|
-
successRate: 0,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
// Extract playbooks: workspace-based when runner available, heuristic otherwise
|
|
147
|
-
let playbooksAdded = 0;
|
|
148
|
-
const existingPlaybooks = await this.memory.playbooks.getAll();
|
|
149
|
-
const playbookExtraction = await this.extractPlaybooks(existingPlaybooks);
|
|
150
|
-
// Add new playbooks
|
|
151
|
-
for (const playbook of playbookExtraction.new) {
|
|
152
|
-
const exists = await this.memory.playbooks.exists(playbook.name, this.config.deduplicationThreshold);
|
|
153
|
-
if (!exists) {
|
|
154
|
-
await this.memory.playbooks.add(playbook);
|
|
155
|
-
playbooksAdded++;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// Apply updates to existing playbooks
|
|
159
|
-
for (const update of playbookExtraction.updates) {
|
|
160
|
-
if (update.refinement) {
|
|
161
|
-
await this.memory.playbooks.addRefinement(update.id, update.refinement.context, update.refinement.addition, update.refinement.source);
|
|
162
|
-
}
|
|
163
|
-
if (update.newTrigger) {
|
|
164
|
-
const playbook = await this.memory.playbooks.get(update.id);
|
|
165
|
-
if (playbook && !playbook.applicability.triggers.includes(update.newTrigger)) {
|
|
166
|
-
playbook.applicability.triggers.push(update.newTrigger);
|
|
167
|
-
await this.memory.playbooks.add(playbook);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (update.newAntiPattern) {
|
|
171
|
-
const playbook = await this.memory.playbooks.get(update.id);
|
|
172
|
-
if (playbook && !playbook.applicability.antiPatterns.includes(update.newAntiPattern)) {
|
|
173
|
-
playbook.applicability.antiPatterns.push(update.newAntiPattern);
|
|
174
|
-
await this.memory.playbooks.add(playbook);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// Temporal compression pass — run after extraction so full-fidelity
|
|
179
|
-
// experience data is available for playbook extraction before compression
|
|
180
|
-
let compressionEvicted = 0;
|
|
181
|
-
let compressionPromoted = 0;
|
|
182
|
-
let compressionDemoted = 0;
|
|
183
|
-
if (this.temporalCompressor) {
|
|
184
|
-
const allExperiences = await this.memory.experiences.getAll();
|
|
185
|
-
const compressionResult = await this.temporalCompressor.compress(allExperiences);
|
|
186
|
-
// Apply compression updates (tier changes, compressed data)
|
|
187
|
-
for (const [id, updates] of compressionResult.updates) {
|
|
188
|
-
await this.memory.experiences.update(id, updates);
|
|
189
|
-
}
|
|
190
|
-
// Evict experiences whose patterns should already be captured in clusters
|
|
191
|
-
for (const id of compressionResult.evicted) {
|
|
192
|
-
await this.memory.experiences.delete(id);
|
|
193
|
-
}
|
|
194
|
-
compressionEvicted = compressionResult.evicted.length;
|
|
195
|
-
compressionPromoted = compressionResult.promoted.length;
|
|
196
|
-
compressionDemoted = compressionResult.demoted.length;
|
|
197
|
-
}
|
|
198
|
-
// Re-cluster experiences in the ReasoningBank for faster retrieval.
|
|
199
|
-
// Uses post-compression experience set so clusters reflect current state.
|
|
200
|
-
const currentExperiences = await this.memory.experiences.getAll();
|
|
201
|
-
if (this.reasoningBank) {
|
|
202
|
-
this.reasoningBank.buildClusters(currentExperiences);
|
|
203
|
-
}
|
|
204
|
-
// Prune experiences if needed
|
|
205
|
-
const pruned = await this.memory.experiences.prune({
|
|
206
|
-
maxCount: this.config.maxExperiences,
|
|
207
|
-
});
|
|
208
|
-
// Calculate success rate
|
|
209
|
-
const successCount = this.accumulatedAnalyses.filter((a) => a.success).length;
|
|
210
|
-
const successRate = successCount / this.accumulated.length;
|
|
211
|
-
// Clear accumulated and update time
|
|
212
|
-
const trajectoriesProcessed = this.accumulated.length;
|
|
213
|
-
this.accumulated = [];
|
|
214
|
-
this.accumulatedAnalyses = [];
|
|
215
|
-
this.lastBatchTime = new Date();
|
|
216
|
-
return {
|
|
217
|
-
trajectoriesProcessed,
|
|
218
|
-
playbooksExtracted: playbooksAdded,
|
|
219
|
-
experiencesPruned: pruned.totalPruned + compressionEvicted,
|
|
220
|
-
experiencesCompressed: {
|
|
221
|
-
promoted: compressionPromoted,
|
|
222
|
-
demoted: compressionDemoted,
|
|
223
|
-
evicted: compressionEvicted,
|
|
224
|
-
},
|
|
225
|
-
experiencesClustered: currentExperiences.length,
|
|
226
|
-
successRate,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Run playbook extraction via the workspace template.
|
|
231
|
-
* Falls back to heuristic extractor on failure.
|
|
232
|
-
*/
|
|
233
|
-
async extractPlaybooks(existingPlaybooks) {
|
|
234
|
-
if (this.taskRunner) {
|
|
235
|
-
try {
|
|
236
|
-
const result = await this.taskRunner.run(playbookExtractionTemplate, {
|
|
237
|
-
trajectories: this.accumulated,
|
|
238
|
-
analyses: this.accumulatedAnalyses,
|
|
239
|
-
existingPlaybooks,
|
|
240
|
-
});
|
|
241
|
-
return result.output;
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
console.error('Workspace-based playbook extraction failed, falling back to heuristic:', error instanceof Error ? error.message : error);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return this.playbookExtractor.extract(this.accumulated, this.accumulatedAnalyses, existingPlaybooks);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Get accumulated trajectory count
|
|
251
|
-
*/
|
|
252
|
-
getAccumulatedCount() {
|
|
253
|
-
return this.accumulated.length;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Get accumulated trajectories with their analyses.
|
|
257
|
-
* Read-only view — does not clear the accumulator.
|
|
258
|
-
*/
|
|
259
|
-
getAccumulated() {
|
|
260
|
-
return this.accumulated.map((trajectory, i) => ({
|
|
261
|
-
trajectory,
|
|
262
|
-
analysis: this.accumulatedAnalyses[i],
|
|
263
|
-
}));
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Clear accumulated trajectories
|
|
267
|
-
*/
|
|
268
|
-
clearAccumulated() {
|
|
269
|
-
this.accumulated = [];
|
|
270
|
-
this.accumulatedAnalyses = [];
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Update configuration
|
|
274
|
-
*/
|
|
275
|
-
updateConfig(config) {
|
|
276
|
-
this.config = { ...this.config, ...config };
|
|
277
|
-
if (config.creditStrategy) {
|
|
278
|
-
this.analyzer.setStrategy(config.creditStrategy);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Create a learning pipeline
|
|
284
|
-
*/
|
|
285
|
-
export function createLearningPipeline(memory, config, featureOptions, persistence) {
|
|
286
|
-
return new LearningPipeline(memory, config, featureOptions, persistence);
|
|
287
|
-
}
|
|
288
|
-
//# sourceMappingURL=pipeline.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/learning/pipeline.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,cAAc,GAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AA2C3F,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAqB;IAC7B,iBAAiB,CAAoB;IACrC,kBAAkB,CAA4B;IAC9C,aAAa,CAAuB;IACpC,MAAM,CAAe;IACrB,MAAM,CAAiB;IAE/B,4DAA4D;IACpD,UAAU,GAA6B,IAAI,CAAC;IAEpD,8CAA8C;IACtC,WAAW,GAAiB,EAAE,CAAC;IAC/B,mBAAmB,GAAqB,EAAE,CAAC;IAC3C,aAAa,GAAgB,IAAI,CAAC;IAE1C,YACE,MAAoB,EAC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EACxB,iBAAiB,CAClB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,UAAU;YACV,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;SACtC,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,MAA+B;QAC1C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;QAC5C,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAoB,EACpB,MAAgC,EAChC,cAAuC,EACvC,WAA+B;IAE/B,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
## Project overview
|
|
4
|
-
|
|
5
|
-
`agent-workspace` is a TypeScript library for managing filesystem workspaces used by AI agents. It provides structured directory layouts, typed readers/writers (JSON, JSONL, Markdown with YAML frontmatter, raw text), and output validation with structured error collection.
|
|
6
|
-
|
|
7
|
-
## Commands
|
|
8
|
-
|
|
9
|
-
- `npm test` — run all tests (vitest)
|
|
10
|
-
- `npm run test:watch` — run tests in watch mode
|
|
11
|
-
- `npm run build` — build with tsup (outputs to `dist/`)
|
|
12
|
-
- `npm run typecheck` — type-check without emitting
|
|
13
|
-
|
|
14
|
-
## Architecture
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
src/
|
|
18
|
-
index.ts ← public API, re-exports everything
|
|
19
|
-
types.ts ← all shared types (Schema, OutputSpec, ValidationResult, etc.)
|
|
20
|
-
manager.ts ← WorkspaceManager: create, list, cleanup, pruneStale
|
|
21
|
-
handle.ts ← WorkspaceHandle: section-scoped I/O facade over readers/writers
|
|
22
|
-
validation.ts ← validateOutput: non-throwing batch output checker
|
|
23
|
-
readers/
|
|
24
|
-
json.ts ← readJson, readJsonl, readJsonDir
|
|
25
|
-
markdown.ts ← readMarkdown (with YAML frontmatter parsing via `yaml` package)
|
|
26
|
-
raw.ts ← readRaw, listFiles
|
|
27
|
-
writers/
|
|
28
|
-
json.ts ← writeJson, writeJsonl
|
|
29
|
-
markdown.ts ← writeMarkdown (with YAML frontmatter serialization)
|
|
30
|
-
raw.ts ← writeRaw, copyDir, symlink
|
|
31
|
-
|
|
32
|
-
tests/
|
|
33
|
-
readers.test.ts ← standalone reader function tests
|
|
34
|
-
writers.test.ts ← standalone writer function tests
|
|
35
|
-
handle.test.ts ← WorkspaceHandle round-trip and section tests
|
|
36
|
-
manager.test.ts ← WorkspaceManager lifecycle tests
|
|
37
|
-
validation.test.ts ← validateOutput tests
|
|
38
|
-
errors.test.ts ← comprehensive parse/validation error behavior tests
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Key design decisions
|
|
42
|
-
|
|
43
|
-
- **Two error strategies**: Reader functions **throw** on errors (for try/catch recovery). `validateOutput` **collects** errors into `{ valid, errors }` (for batch checking). Never mix these — readers always throw, validation never throws.
|
|
44
|
-
- **Schema interface**: `{ parse(data: unknown): T }` — deliberately minimal so it works with Zod, Joi, or any custom implementation. `parse` must throw on invalid data.
|
|
45
|
-
- **Section-scoped I/O**: `WorkspaceHandle` methods take a section name (`'input'`, `'output'`, `'resources'`, `'scratch'`, or custom) as the first argument. `handle.dir(section)` throws synchronously if the section is unknown.
|
|
46
|
-
- **Default dirs**: `input`, `output`, `resources`, `scratch` are always created. Additional dirs are specified at `manager.create()` time.
|
|
47
|
-
- **Workspace metadata**: Each workspace writes `.workspace.json` with `{ id, taskType, createdAt, dirs }`. The manager uses this to reconstruct handles when listing.
|
|
48
|
-
|
|
49
|
-
## Conventions
|
|
50
|
-
|
|
51
|
-
- ESM-first (`"type": "module"` in package.json), dual CJS/ESM output via tsup.
|
|
52
|
-
- All file path parameters in readers/writers are relative to the `dir` argument. Writers auto-create parent directories via `fs.mkdir({ recursive: true })`.
|
|
53
|
-
- Tests use temp directories (`os.tmpdir()` + `fs.mkdtemp`) and clean up in `afterEach`.
|
|
54
|
-
- No external dependencies except `yaml` for YAML parsing/serialization.
|
|
55
|
-
- TypeScript strict mode. Target ES2022.
|
|
56
|
-
|
|
57
|
-
## Error message contracts
|
|
58
|
-
|
|
59
|
-
Error messages are intentionally detailed to support agent re-prompting:
|
|
60
|
-
|
|
61
|
-
- `readJson` on bad JSON: native `JSON.parse` SyntaxError
|
|
62
|
-
- `readJson` schema failure: the schema's own error message (e.g., Zod's)
|
|
63
|
-
- `readJsonl` schema failure: `"JSONL validation failed at line N: <schema error>"`
|
|
64
|
-
- `handle.dir()` unknown section: `'Unknown section "X". Available: input, output, ...'`
|
|
65
|
-
- `validateOutput` errors: `{ path: string, message: string }` — path identifies the file, message describes the issue
|
|
66
|
-
|
|
67
|
-
## Testing
|
|
68
|
-
|
|
69
|
-
The test suite has 101 tests across 6 files. When adding new functionality:
|
|
70
|
-
|
|
71
|
-
- Add happy-path tests to the relevant existing test file (`readers.test.ts`, `handle.test.ts`, etc.)
|
|
72
|
-
- Add error/throw behavior tests to `errors.test.ts`
|
|
73
|
-
- All reader error paths must be tested: missing file, malformed content, schema rejection
|
|
74
|
-
- Validation tests must verify that errors are **collected** (not thrown) and include both `path` and `message`
|