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,353 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Separate Session Repository Support
|
|
3
|
-
*
|
|
4
|
-
* Covers: getProjectID, resolveSessionRepoPath, initSessionRepo,
|
|
5
|
-
* createSessionStore with custom sessionsDir, createCheckpointStore
|
|
6
|
-
* with sessionRepoCwd, and strategy sessionRepoCwd wiring.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
10
|
-
import * as fs from 'node:fs';
|
|
11
|
-
import * as os from 'node:os';
|
|
12
|
-
import * as path from 'node:path';
|
|
13
|
-
import { execFileSync } from 'node:child_process';
|
|
14
|
-
import { getProjectID, resolveSessionRepoPath, initSessionRepo } from '../git-operations.js';
|
|
15
|
-
import { createSessionStore } from '../store/session-store.js';
|
|
16
|
-
import { createCheckpointStore } from '../store/checkpoint-store.js';
|
|
17
|
-
|
|
18
|
-
// ============================================================================
|
|
19
|
-
// getProjectID
|
|
20
|
-
// ============================================================================
|
|
21
|
-
|
|
22
|
-
describe('getProjectID', () => {
|
|
23
|
-
it('should return <dir-name>-<hash> format', () => {
|
|
24
|
-
const id = getProjectID('/home/user/my-project');
|
|
25
|
-
expect(id).toMatch(/^my-project-[a-f0-9]{8}$/);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should sanitize directory name to lowercase', () => {
|
|
29
|
-
const id = getProjectID('/home/user/MyProject');
|
|
30
|
-
expect(id).toMatch(/^myproject-[a-f0-9]{8}$/);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should replace non-alphanumeric characters with hyphens', () => {
|
|
34
|
-
const id = getProjectID('/home/user/my_project.v2');
|
|
35
|
-
expect(id).toMatch(/^my-project-v2-[a-f0-9]{8}$/);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should collapse consecutive hyphens', () => {
|
|
39
|
-
const id = getProjectID('/home/user/my---project');
|
|
40
|
-
expect(id).toMatch(/^my-project-[a-f0-9]{8}$/);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should trim leading/trailing hyphens from sanitized name', () => {
|
|
44
|
-
const id = getProjectID('/home/user/---project---');
|
|
45
|
-
expect(id).toMatch(/^project-[a-f0-9]{8}$/);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should use "project" as fallback for empty directory name after sanitization', () => {
|
|
49
|
-
const id = getProjectID('/home/user/...');
|
|
50
|
-
expect(id).toMatch(/^project-[a-f0-9]{8}$/);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should produce different hashes for different absolute paths with same dir name', () => {
|
|
54
|
-
const id1 = getProjectID('/home/alice/my-project');
|
|
55
|
-
const id2 = getProjectID('/home/bob/my-project');
|
|
56
|
-
// Same prefix, different hash
|
|
57
|
-
expect(id1.startsWith('my-project-')).toBe(true);
|
|
58
|
-
expect(id2.startsWith('my-project-')).toBe(true);
|
|
59
|
-
expect(id1).not.toBe(id2);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should be deterministic for the same input', () => {
|
|
63
|
-
const id1 = getProjectID('/home/user/repo');
|
|
64
|
-
const id2 = getProjectID('/home/user/repo');
|
|
65
|
-
expect(id1).toBe(id2);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should resolve relative paths consistently', () => {
|
|
69
|
-
// path.resolve will make relative paths absolute based on cwd
|
|
70
|
-
const id = getProjectID('relative/path');
|
|
71
|
-
expect(id).toMatch(/^path-[a-f0-9]{8}$/);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// ============================================================================
|
|
76
|
-
// resolveSessionRepoPath
|
|
77
|
-
// ============================================================================
|
|
78
|
-
|
|
79
|
-
describe('resolveSessionRepoPath', () => {
|
|
80
|
-
it('should resolve relative path against project root', () => {
|
|
81
|
-
const result = resolveSessionRepoPath('../session-data', '/home/user/project');
|
|
82
|
-
expect(result).toBe('/home/user/session-data');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should return absolute path unchanged', () => {
|
|
86
|
-
const result = resolveSessionRepoPath('/opt/session-data', '/home/user/project');
|
|
87
|
-
expect(result).toBe('/opt/session-data');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should resolve relative paths within project root', () => {
|
|
91
|
-
const result = resolveSessionRepoPath('.sessionlog-sessions', '/home/user/project');
|
|
92
|
-
expect(result).toBe('/home/user/project/.sessionlog-sessions');
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// ============================================================================
|
|
97
|
-
// initSessionRepo
|
|
98
|
-
// ============================================================================
|
|
99
|
-
|
|
100
|
-
describe('initSessionRepo', () => {
|
|
101
|
-
let tmpDir: string;
|
|
102
|
-
let savedEnv: Record<string, string | undefined>;
|
|
103
|
-
|
|
104
|
-
beforeEach(() => {
|
|
105
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'session-repo-test-'));
|
|
106
|
-
// Disable commit signing and system git config for test isolation
|
|
107
|
-
savedEnv = {
|
|
108
|
-
GIT_CONFIG_NOSYSTEM: process.env.GIT_CONFIG_NOSYSTEM,
|
|
109
|
-
GIT_CONFIG_GLOBAL: process.env.GIT_CONFIG_GLOBAL,
|
|
110
|
-
};
|
|
111
|
-
process.env.GIT_CONFIG_NOSYSTEM = '1';
|
|
112
|
-
process.env.GIT_CONFIG_GLOBAL = '/dev/null';
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
afterEach(() => {
|
|
116
|
-
// Restore environment
|
|
117
|
-
for (const [key, val] of Object.entries(savedEnv)) {
|
|
118
|
-
if (val === undefined) {
|
|
119
|
-
delete process.env[key];
|
|
120
|
-
} else {
|
|
121
|
-
process.env[key] = val;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('should create a new git repo at the given path', async () => {
|
|
128
|
-
const repoPath = path.join(tmpDir, 'sessions');
|
|
129
|
-
const result = await initSessionRepo(repoPath);
|
|
130
|
-
|
|
131
|
-
expect(result).toBe(path.resolve(repoPath));
|
|
132
|
-
expect(fs.existsSync(path.join(repoPath, '.git'))).toBe(true);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('should create an initial commit', async () => {
|
|
136
|
-
const repoPath = path.join(tmpDir, 'sessions');
|
|
137
|
-
await initSessionRepo(repoPath);
|
|
138
|
-
|
|
139
|
-
// Verify there's at least one commit
|
|
140
|
-
const log = execFileSync('git', ['log', '--oneline'], {
|
|
141
|
-
cwd: repoPath,
|
|
142
|
-
encoding: 'utf-8',
|
|
143
|
-
env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null' },
|
|
144
|
-
});
|
|
145
|
-
expect(log).toContain('Initialize session repository');
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should be idempotent - not fail on existing repo', async () => {
|
|
149
|
-
const repoPath = path.join(tmpDir, 'sessions');
|
|
150
|
-
|
|
151
|
-
// Initialize once
|
|
152
|
-
await initSessionRepo(repoPath);
|
|
153
|
-
|
|
154
|
-
// Initialize again - should not throw
|
|
155
|
-
const result = await initSessionRepo(repoPath);
|
|
156
|
-
expect(result).toBe(path.resolve(repoPath));
|
|
157
|
-
|
|
158
|
-
// Should still have only the initial commit
|
|
159
|
-
const log = execFileSync('git', ['log', '--oneline'], {
|
|
160
|
-
cwd: repoPath,
|
|
161
|
-
encoding: 'utf-8',
|
|
162
|
-
env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null' },
|
|
163
|
-
});
|
|
164
|
-
const lines = log.trim().split('\n');
|
|
165
|
-
expect(lines.length).toBe(1);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should create nested directories if needed', async () => {
|
|
169
|
-
const repoPath = path.join(tmpDir, 'deep', 'nested', 'sessions');
|
|
170
|
-
const result = await initSessionRepo(repoPath);
|
|
171
|
-
|
|
172
|
-
expect(result).toBe(path.resolve(repoPath));
|
|
173
|
-
expect(fs.existsSync(path.join(repoPath, '.git'))).toBe(true);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// ============================================================================
|
|
178
|
-
// createSessionStore with custom sessionsDir
|
|
179
|
-
// ============================================================================
|
|
180
|
-
|
|
181
|
-
describe('createSessionStore with custom sessionsDir', () => {
|
|
182
|
-
let tmpDir: string;
|
|
183
|
-
|
|
184
|
-
beforeEach(() => {
|
|
185
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'session-store-test-'));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
afterEach(() => {
|
|
189
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should use the custom sessionsDir for getDir()', async () => {
|
|
193
|
-
const customDir = path.join(tmpDir, 'custom-sessions');
|
|
194
|
-
fs.mkdirSync(customDir, { recursive: true });
|
|
195
|
-
|
|
196
|
-
const store = createSessionStore(undefined, customDir);
|
|
197
|
-
const dir = await store.getDir();
|
|
198
|
-
expect(dir).toBe(customDir);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('should save and load sessions from custom directory', async () => {
|
|
202
|
-
const customDir = path.join(tmpDir, 'custom-sessions');
|
|
203
|
-
fs.mkdirSync(customDir, { recursive: true });
|
|
204
|
-
|
|
205
|
-
const store = createSessionStore(undefined, customDir);
|
|
206
|
-
|
|
207
|
-
const state = {
|
|
208
|
-
sessionID: 'test-session-123',
|
|
209
|
-
baseCommit: 'abc123',
|
|
210
|
-
startedAt: new Date().toISOString(),
|
|
211
|
-
phase: 'active' as const,
|
|
212
|
-
agentType: 'Claude Code',
|
|
213
|
-
filesTouched: ['src/app.ts'],
|
|
214
|
-
stepCount: 1,
|
|
215
|
-
turnCheckpointIDs: [],
|
|
216
|
-
untrackedFilesAtStart: [],
|
|
217
|
-
checkpointTranscriptStart: 0,
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
await store.save(state);
|
|
221
|
-
|
|
222
|
-
// Verify file exists in custom directory
|
|
223
|
-
const filePath = path.join(customDir, 'test-session-123.json');
|
|
224
|
-
expect(fs.existsSync(filePath)).toBe(true);
|
|
225
|
-
|
|
226
|
-
// Verify load works
|
|
227
|
-
const loaded = await store.load('test-session-123');
|
|
228
|
-
expect(loaded).not.toBeNull();
|
|
229
|
-
expect(loaded!.sessionID).toBe('test-session-123');
|
|
230
|
-
expect(loaded!.baseCommit).toBe('abc123');
|
|
231
|
-
expect(loaded!.agentType).toBe('Claude Code');
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should list sessions from custom directory', async () => {
|
|
235
|
-
const customDir = path.join(tmpDir, 'custom-sessions');
|
|
236
|
-
fs.mkdirSync(customDir, { recursive: true });
|
|
237
|
-
|
|
238
|
-
const store = createSessionStore(undefined, customDir);
|
|
239
|
-
|
|
240
|
-
// Save two sessions
|
|
241
|
-
const state1 = {
|
|
242
|
-
sessionID: 'session-a',
|
|
243
|
-
baseCommit: 'abc',
|
|
244
|
-
startedAt: new Date().toISOString(),
|
|
245
|
-
phase: 'active' as const,
|
|
246
|
-
agentType: 'Claude Code',
|
|
247
|
-
filesTouched: [],
|
|
248
|
-
stepCount: 0,
|
|
249
|
-
turnCheckpointIDs: [],
|
|
250
|
-
untrackedFilesAtStart: [],
|
|
251
|
-
checkpointTranscriptStart: 0,
|
|
252
|
-
};
|
|
253
|
-
const state2 = {
|
|
254
|
-
...state1,
|
|
255
|
-
sessionID: 'session-b',
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
await store.save(state1);
|
|
259
|
-
await store.save(state2);
|
|
260
|
-
|
|
261
|
-
const sessions = await store.list();
|
|
262
|
-
const ids = sessions.map((s) => s.sessionID).sort();
|
|
263
|
-
expect(ids).toEqual(['session-a', 'session-b']);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('should delete sessions from custom directory', async () => {
|
|
267
|
-
const customDir = path.join(tmpDir, 'custom-sessions');
|
|
268
|
-
fs.mkdirSync(customDir, { recursive: true });
|
|
269
|
-
|
|
270
|
-
const store = createSessionStore(undefined, customDir);
|
|
271
|
-
|
|
272
|
-
const state = {
|
|
273
|
-
sessionID: 'to-delete',
|
|
274
|
-
baseCommit: 'abc',
|
|
275
|
-
startedAt: new Date().toISOString(),
|
|
276
|
-
phase: 'ended' as const,
|
|
277
|
-
agentType: 'Claude Code',
|
|
278
|
-
filesTouched: [],
|
|
279
|
-
stepCount: 0,
|
|
280
|
-
turnCheckpointIDs: [],
|
|
281
|
-
untrackedFilesAtStart: [],
|
|
282
|
-
checkpointTranscriptStart: 0,
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
await store.save(state);
|
|
286
|
-
expect(await store.exists('to-delete')).toBe(true);
|
|
287
|
-
|
|
288
|
-
await store.delete('to-delete');
|
|
289
|
-
expect(await store.exists('to-delete')).toBe(false);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
// ============================================================================
|
|
294
|
-
// createCheckpointStore with sessionRepoCwd and checkpointsBranch
|
|
295
|
-
// ============================================================================
|
|
296
|
-
|
|
297
|
-
describe('createCheckpointStore with sessionRepoCwd', () => {
|
|
298
|
-
it('should accept sessionRepoCwd and checkpointsBranch parameters', () => {
|
|
299
|
-
// Verify the function doesn't throw when given these parameters
|
|
300
|
-
const store = createCheckpointStore(
|
|
301
|
-
'/tmp/project',
|
|
302
|
-
'/tmp/session-repo',
|
|
303
|
-
'sessionlog/checkpoints/v1/my-project-abc123',
|
|
304
|
-
);
|
|
305
|
-
expect(store).toBeDefined();
|
|
306
|
-
expect(store.generateID).toBeInstanceOf(Function);
|
|
307
|
-
expect(store.writeTemporary).toBeInstanceOf(Function);
|
|
308
|
-
expect(store.writeCommitted).toBeInstanceOf(Function);
|
|
309
|
-
expect(store.readCommitted).toBeInstanceOf(Function);
|
|
310
|
-
expect(store.listCommitted).toBeInstanceOf(Function);
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it('should generate valid checkpoint IDs regardless of repo config', async () => {
|
|
314
|
-
const store = createCheckpointStore(undefined, '/tmp/session-repo', 'custom/branch');
|
|
315
|
-
const id = await store.generateID();
|
|
316
|
-
expect(id).toMatch(/^[a-f0-9]+$/);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// ============================================================================
|
|
321
|
-
// Project namespacing integration
|
|
322
|
-
// ============================================================================
|
|
323
|
-
|
|
324
|
-
describe('Project Namespacing', () => {
|
|
325
|
-
it('should produce correct namespaced checkpoints branch', () => {
|
|
326
|
-
const projectID = getProjectID('/home/user/my-project');
|
|
327
|
-
const cpBranch = `sessionlog/checkpoints/v1/${projectID}`;
|
|
328
|
-
expect(cpBranch).toMatch(/^sessionlog\/checkpoints\/v1\/my-project-[a-f0-9]{8}$/);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('should produce correct namespaced sessions directory', () => {
|
|
332
|
-
const projectID = getProjectID('/home/user/my-project');
|
|
333
|
-
const sessionsDir = `/opt/session-repo/sessionlog-sessions/${projectID}`;
|
|
334
|
-
expect(sessionsDir).toMatch(
|
|
335
|
-
/^\/opt\/session-repo\/sessionlog-sessions\/my-project-[a-f0-9]{8}$/,
|
|
336
|
-
);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('should keep different projects isolated', () => {
|
|
340
|
-
const id1 = getProjectID('/home/user/project-a');
|
|
341
|
-
const id2 = getProjectID('/home/user/project-b');
|
|
342
|
-
|
|
343
|
-
const branch1 = `sessionlog/checkpoints/v1/${id1}`;
|
|
344
|
-
const branch2 = `sessionlog/checkpoints/v1/${id2}`;
|
|
345
|
-
|
|
346
|
-
expect(branch1).not.toBe(branch2);
|
|
347
|
-
|
|
348
|
-
const dir1 = `sessionlog-sessions/${id1}`;
|
|
349
|
-
const dir2 = `sessionlog-sessions/${id2}`;
|
|
350
|
-
|
|
351
|
-
expect(dir1).not.toBe(dir2);
|
|
352
|
-
});
|
|
353
|
-
});
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Session Store Normalization
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { normalizeSessionState } from '../store/session-store.js';
|
|
7
|
-
|
|
8
|
-
describe('Session Store', () => {
|
|
9
|
-
describe('normalizeSessionState', () => {
|
|
10
|
-
it('should normalize standard fields', () => {
|
|
11
|
-
const state = normalizeSessionState('test-id', {
|
|
12
|
-
sessionID: 'test-id',
|
|
13
|
-
baseCommit: 'abc123',
|
|
14
|
-
startedAt: '2026-02-13T12:00:00Z',
|
|
15
|
-
phase: 'active',
|
|
16
|
-
agentType: 'Claude Code',
|
|
17
|
-
filesTouched: ['src/app.ts'],
|
|
18
|
-
stepCount: 3,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
expect(state.sessionID).toBe('test-id');
|
|
22
|
-
expect(state.baseCommit).toBe('abc123');
|
|
23
|
-
expect(state.phase).toBe('active');
|
|
24
|
-
expect(state.agentType).toBe('Claude Code');
|
|
25
|
-
expect(state.filesTouched).toEqual(['src/app.ts']);
|
|
26
|
-
expect(state.stepCount).toBe(3);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should handle alternative field names', () => {
|
|
30
|
-
const state = normalizeSessionState('alt-id', {
|
|
31
|
-
session_id: 'alt-id',
|
|
32
|
-
base_commit: 'def456',
|
|
33
|
-
started_at: '2026-02-13T12:00:00Z',
|
|
34
|
-
state: 'ACTIVE',
|
|
35
|
-
agent: 'Cursor IDE',
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
expect(state.sessionID).toBe('alt-id');
|
|
39
|
-
expect(state.phase).toBe('active');
|
|
40
|
-
expect(state.agentType).toBe('Cursor IDE');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should normalize phase values', () => {
|
|
44
|
-
expect(normalizeSessionState('id', { phase: 'ACTIVE' }).phase).toBe('active');
|
|
45
|
-
expect(normalizeSessionState('id', { phase: 'IDLE' }).phase).toBe('idle');
|
|
46
|
-
expect(normalizeSessionState('id', { phase: 'ENDED' }).phase).toBe('ended');
|
|
47
|
-
expect(normalizeSessionState('id', { phase: 'unknown' }).phase).toBe('idle');
|
|
48
|
-
expect(normalizeSessionState('id', {}).phase).toBe('idle');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should default missing arrays to empty', () => {
|
|
52
|
-
const state = normalizeSessionState('id', {});
|
|
53
|
-
expect(state.filesTouched).toEqual([]);
|
|
54
|
-
expect(state.turnCheckpointIDs).toEqual([]);
|
|
55
|
-
expect(state.untrackedFilesAtStart).toEqual([]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should default missing numbers to 0', () => {
|
|
59
|
-
const state = normalizeSessionState('id', {});
|
|
60
|
-
expect(state.stepCount).toBe(0);
|
|
61
|
-
expect(state.checkpointTranscriptStart).toBe(0);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should use id parameter as fallback for sessionID', () => {
|
|
65
|
-
const state = normalizeSessionState('fallback-id', {});
|
|
66
|
-
expect(state.sessionID).toBe('fallback-id');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should preserve optional fields when present', () => {
|
|
70
|
-
const state = normalizeSessionState('id', {
|
|
71
|
-
firstPrompt: 'Build a REST API',
|
|
72
|
-
transcriptPath: '/path/to/transcript.jsonl',
|
|
73
|
-
endedAt: '2026-02-13T13:00:00Z',
|
|
74
|
-
worktreeID: 'main',
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
expect(state.firstPrompt).toBe('Build a REST API');
|
|
78
|
-
expect(state.transcriptPath).toBe('/path/to/transcript.jsonl');
|
|
79
|
-
expect(state.endedAt).toBe('2026-02-13T13:00:00Z');
|
|
80
|
-
expect(state.worktreeID).toBe('main');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should normalize task tracking fields', () => {
|
|
84
|
-
const tasks = {
|
|
85
|
-
'1': {
|
|
86
|
-
id: '1',
|
|
87
|
-
subject: 'Fix bug',
|
|
88
|
-
status: 'completed',
|
|
89
|
-
createdAt: '2026-02-13T12:00:00Z',
|
|
90
|
-
updatedAt: '2026-02-13T12:30:00Z',
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
const state = normalizeSessionState('id', {
|
|
94
|
-
tasks,
|
|
95
|
-
inPlanMode: true,
|
|
96
|
-
planModeEntries: 2,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
expect(state.tasks).toEqual(tasks);
|
|
100
|
-
expect(state.inPlanMode).toBe(true);
|
|
101
|
-
expect(state.planModeEntries).toBe(2);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should handle missing task/plan fields for backward compatibility', () => {
|
|
105
|
-
const state = normalizeSessionState('id', {});
|
|
106
|
-
expect(state.tasks).toBeUndefined();
|
|
107
|
-
expect(state.inPlanMode).toBeUndefined();
|
|
108
|
-
expect(state.planModeEntries).toBeUndefined();
|
|
109
|
-
expect(state.planEntries).toBeUndefined();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('should normalize planEntries array', () => {
|
|
113
|
-
const entries = [
|
|
114
|
-
{
|
|
115
|
-
enteredAt: '2026-02-13T12:00:00Z',
|
|
116
|
-
exitedAt: '2026-02-13T12:05:00Z',
|
|
117
|
-
filePath: '/home/user/.claude/plans/my-plan.md',
|
|
118
|
-
content: '# Plan\n\nStep 1: Do the thing',
|
|
119
|
-
},
|
|
120
|
-
];
|
|
121
|
-
const state = normalizeSessionState('id', { planEntries: entries });
|
|
122
|
-
expect(state.planEntries).toEqual(entries);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should migrate old planFilePath/planContent to planEntries', () => {
|
|
126
|
-
const state = normalizeSessionState('id', {
|
|
127
|
-
planFilePath: '/home/user/.claude/plans/my-plan.md',
|
|
128
|
-
planContent: '# Plan\n\nStep 1: Do the thing',
|
|
129
|
-
startedAt: '2026-02-13T12:00:00Z',
|
|
130
|
-
});
|
|
131
|
-
expect(state.planEntries).toHaveLength(1);
|
|
132
|
-
expect(state.planEntries![0].filePath).toBe('/home/user/.claude/plans/my-plan.md');
|
|
133
|
-
expect(state.planEntries![0].content).toBe('# Plan\n\nStep 1: Do the thing');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('should normalize multiple planEntries', () => {
|
|
137
|
-
const entries = [
|
|
138
|
-
{ enteredAt: '2026-02-13T12:00:00Z', exitedAt: '2026-02-13T12:05:00Z' },
|
|
139
|
-
{
|
|
140
|
-
enteredAt: '2026-02-13T13:00:00Z',
|
|
141
|
-
exitedAt: '2026-02-13T13:10:00Z',
|
|
142
|
-
filePath: '/plans/v2.md',
|
|
143
|
-
content: '# V2 Plan',
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
const state = normalizeSessionState('id', { planEntries: entries });
|
|
147
|
-
expect(state.planEntries).toHaveLength(2);
|
|
148
|
-
expect(state.planEntries![1].filePath).toBe('/plans/v2.md');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('should normalize task description field', () => {
|
|
152
|
-
const tasks = {
|
|
153
|
-
'1': {
|
|
154
|
-
id: '1',
|
|
155
|
-
subject: 'Fix bug',
|
|
156
|
-
description: 'Detailed description of the bug',
|
|
157
|
-
status: 'pending',
|
|
158
|
-
createdAt: '2026-02-13T12:00:00Z',
|
|
159
|
-
updatedAt: '2026-02-13T12:00:00Z',
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
const state = normalizeSessionState('id', { tasks });
|
|
163
|
-
expect(state.tasks!['1'].description).toBe('Detailed description of the bug');
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
});
|