kenaz 0.3.18 → 0.3.19
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/core/.claude/commands/agent-worker.md +1 -1
- package/core/.claude/commands/architect.md +1 -2
- package/core/.claude/commands/spec.md +1 -1
- package/core/.claude/commands//347/224/242/345/223/201.md +1 -1
- package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +8 -8
- package/core/.claude/skills/architect_agent/SKILL.md +11 -92
- package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
- package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
- package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
- package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
- package/core/.claude/skills/designer/SKILL.md +3 -6
- package/core/.claude/skills/dev_agent/SKILL.md +30 -491
- package/core/.claude/skills/developer/SKILL.md +3 -6
- package/core/.claude/skills/feature_agent/SKILL.md +3 -17
- package/core/.claude/skills/product_manager/SKILL.md +29 -1064
- package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
- package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
- package/core/.claude/skills/sre_agent/SKILL.md +3 -6
- package/core/.collaboration/README.md +2 -3
- package/core/.collaboration/core/task-api.js +5 -138
- package/core/.collaboration/docs/CLI.md +0 -2
- package/core/.failure/INDEX.yaml +6 -40
- package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
- package/core/.failure/tools/README.md +9 -227
- package/core/.formation/bifrost/launch.js +1 -6
- package/core/.formation/bifrost/launch.test.js +1 -1
- package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
- package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
- package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
- package/core/.formation/tools/dispatch.js +1 -1
- package/core/.formation/tools/loader.js +17 -140
- package/core/.formation/tools/post-complete.js +0 -31
- package/core/.rule/INDEX.yaml +0 -18
- package/core/.rule/general/agent-workflow.yaml +14 -164
- package/core/.rule/general/project-self-containment.yaml +8 -19
- package/core/.rule/general/rust-verify-target.yaml +6 -5
- package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
- package/core/.specialist/Amelia/capability.yaml +12 -12
- package/core/.specialist/Amelia/workflow.yaml +2 -2
- package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
- package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
- package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
- package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
- package/core/.specialist/Ansuz/core.yaml +6 -108
- package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
- package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
- package/core/.specialist/Ansuz/knowledge.yaml +0 -4
- package/core/.specialist/Ansuz/rule.yaml +0 -1
- package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
- package/core/.specialist/tests/runtime-discovery/README.md +1 -1
- package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
- package/core/.specialist/tools/prompt-files.test.js +1 -0
- package/core/.specialist/tools/task-bridge.js +1 -66
- package/core/.system/README.md +11 -552
- package/core/.system/collaboration/README.md +10 -174
- package/core/CLAUDE.md +1 -6
- package/core/KENAZ_CORE_VERSION +1 -1
- package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
- package/core/dev/scripts/run-rust-tests.js +9 -45
- package/core/dev/scripts/rust-verify-worktree.js +4 -4
- package/core/dev/scripts/verify-target-dir.js +6 -6
- package/core/plugins/kenaz/INVENTORY.md +8 -8
- package/core/plugins/kenaz/commands/architect.md +1 -2
- package/core/plugins/kenaz/commands/spec.md +1 -1
- package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
- package/core/plugins/kenaz/guidance.md +1 -1
- package/core/plugins/kenaz/scripts/sync.js +1 -1
- package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
- package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
- package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
- package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
- package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
- package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
- package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
- package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
- package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
- package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
- package/package.json +6 -6
- package/core/.claude/commands/archive.md +0 -24
- package/core/.claude/commands/init.md +0 -112
- package/core/.claude/commands/legacy_dev.md +0 -18
- package/core/.claude/commands/product-review.md +0 -131
- package/core/.claude/commands/strategy.md +0 -141
- package/core/.claude/commands/sunny.md +0 -1
- package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
- package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
- package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
- package/core/.claude/hooks/_substrate-paths.js +0 -95
- package/core/.claude/hooks/context-check.js +0 -51
- package/core/.claude/hooks/fatigue-check.js +0 -52
- package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
- package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
- package/core/.claude/hooks/handoff-staleness.js +0 -197
- package/core/.claude/hooks/jev-thalamus-context.js +0 -17
- package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
- package/core/.claude/hooks/lease-release.js +0 -119
- package/core/.claude/hooks/lease-touch.js +0 -96
- package/core/.claude/hooks/reflex-feedback.js +0 -5
- package/core/.claude/hooks/session-init.ps1 +0 -49
- package/core/.claude/hooks/sound-event.js +0 -70
- package/core/.claude/hooks/sound-event.sh +0 -37
- package/core/.claude/hooks/stream-delta.js +0 -169
- package/core/.claude/no-hooks.settings.json +0 -3
- package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
- package/core/.claude/skills/sunny/SKILL.md +0 -74
- package/core/.collaboration/cli/commands/assign.js +0 -39
- package/core/.collaboration/cli/commands/claim.js +0 -33
- package/core/.collaboration/cli/commands/complete.js +0 -44
- package/core/.collaboration/cli/commands/create.js +0 -110
- package/core/.collaboration/cli/commands/get.js +0 -83
- package/core/.collaboration/cli/commands/index.js +0 -52
- package/core/.collaboration/cli/commands/list.js +0 -51
- package/core/.collaboration/cli/commands/lock.js +0 -45
- package/core/.collaboration/cli/commands/rebuild.js +0 -39
- package/core/.collaboration/cli/commands/search.js +0 -61
- package/core/.collaboration/cli/commands/stats.js +0 -61
- package/core/.collaboration/cli/commands/transfer.js +0 -41
- package/core/.collaboration/cli/commands/unlock.js +0 -48
- package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
- package/core/.collaboration/cli/formatters/index.js +0 -7
- package/core/.collaboration/cli/task-cli.js +0 -46
- package/core/.collaboration/cli/utils/arg-parser.js +0 -74
- package/core/.collaboration/cli/utils/git-user.js +0 -25
- package/core/.collaboration/cli/utils/index.js +0 -9
- package/core/.collaboration/cli/utils/output.js +0 -10
- package/core/.collaboration/config/default.yaml +0 -189
- package/core/.collaboration/core/conflict-resolver.js +0 -461
- package/core/.collaboration/core/conflict-resolver.test.js +0 -389
- package/core/.collaboration/core/migrate-legacy.js +0 -260
- package/core/.collaboration/docs/API.md +0 -787
- package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
- package/core/.collaboration/docs/FAQ.md +0 -695
- package/core/.collaboration/docs/MIGRATION.md +0 -804
- package/core/.collaboration/docs/examples/README.md +0 -320
- package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
- package/core/.collaboration/docs/examples/basic-usage.js +0 -184
- package/core/.collaboration/docs/examples/team-workflow.js +0 -352
- package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
- package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
- package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
- package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
- package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
- package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
- package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
- package/core/.failure/pipeline/README.md +0 -95
- package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
- package/core/.failure/tools/USAGE_GUIDE.md +0 -323
- package/core/.failure/tools/check_failures.ps1 +0 -387
- package/core/.failure/tools/log_failure.ps1 +0 -474
- package/core/.formation/.episode-input.json +0 -10
- package/core/.formation/.merge-lock +0 -1
- package/core/.formation/lead.yaml +0 -118
- package/core/.formation/legacy.bak/designer.yaml +0 -57
- package/core/.formation/legacy.bak/pm.yaml +0 -57
- package/core/.formation/legacy.bak/qa.yaml +0 -57
- package/core/.formation/legacy.bak/review.yaml +0 -62
- package/core/.formation/legacy.bak/scheduler.yaml +0 -129
- package/core/.formation/legacy.bak/sre.yaml +0 -57
- package/core/.formation/role-map.yaml +0 -274
- package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
- package/core/.formation/roles/_shared/modules/security.yaml +0 -103
- package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
- package/core/.formation/roles/backend/role.yaml +0 -93
- package/core/.formation/roles/code_reviewer/role.yaml +0 -102
- package/core/.formation/roles/database_optimizer/role.yaml +0 -107
- package/core/.formation/roles/designer/role.yaml +0 -66
- package/core/.formation/roles/developer/role.yaml +0 -75
- package/core/.formation/roles/frontend/role.yaml +0 -134
- package/core/.formation/roles/incident_response/role.yaml +0 -89
- package/core/.formation/roles/qa/role.yaml +0 -89
- package/core/.formation/roles/security/role.yaml +0 -87
- package/core/.formation/roles/sre/role.yaml +0 -66
- package/core/.formation/skills/coordinator.yaml +0 -52
- package/core/.formation/solo/diagnosis.yaml +0 -78
- package/core/.formation/solo/strategy.yaml +0 -121
- package/core/.formation/tests/hello.txt +0 -2
- package/core/.formation/tools/coordinator.js +0 -350
- package/core/.formation/tools/jev-correction.js +0 -214
- package/core/.formation/tools/jev-correction.test.js +0 -178
- package/core/.formation/tools/log-reader.js +0 -232
- package/core/.formation/tools/revert-daemon-state.js +0 -162
- package/core/.formation/tools/test-drift.js +0 -148
- package/core/.formation/unit/heimdall.yaml +0 -96
- package/core/.formation/unit/plan.yaml +0 -67
- package/core/.formation/unit/think.yaml +0 -58
- package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
- package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
- package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
- package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
- package/core/.kenaz/muninn_episode_write.ps1 +0 -17
- package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
- package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
- package/core/.kenaz/runes_TASK_1428.json +0 -57
- package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
- package/core/.kenaz/tmp_props.json +0 -1
- package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
- package/core/.rule/MECHANIZED.md +0 -61
- package/core/.rule/general/cortex-memory-recall.yaml +0 -446
- package/core/.rule/general/pipeline.yaml +0 -246
- package/core/.rule/general/sunny-access-control.yaml +0 -60
- package/core/.rule/general/system-invariants.yaml +0 -231
- package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
- package/core/.rule/pipeline/auto-update.yaml +0 -282
- package/core/.rule/pipeline/task-execution.yaml +0 -365
- package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
- package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
- package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
- package/core/.specialist/Ansuz/workflow.yaml +0 -1225
- package/core/.specialist/experiments/rg_benchmark.js +0 -523
- package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
- package/core/.specialist/tools/jev-optional-context.js +0 -107
- package/core/.specialist/tools/jev-optional-context.test.js +0 -152
- package/core/.specialist/tools/memory-action-log.js +0 -839
- package/core/.specialist/tools/phase-gate.js +0 -3534
- package/core/.specialist/tools/phase-gate.test.js +0 -85
- package/core/.specialist/tools/precompute-runner.js +0 -444
- package/core/.specialist/tools/rule-engine.js +0 -621
- package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
- package/core/.synapse/memory-shared.json.sync +0 -1
- package/core/.system/agent-skills/README.md +0 -724
- package/core/.system/cli-tools/README.md +0 -724
- package/core/.system/cortex/MODULES.md +0 -1046
- package/core/.system/dashboard/FRONTEND.md +0 -812
- package/core/.system/dashboard/README.md +0 -737
- package/core/.system/failure/README.md +0 -723
- package/core/.system/formation/LEGACY_SKILLS.md +0 -974
- package/core/.system/formation/POST_COMPLETE.md +0 -602
- package/core/.system/formation/README.md +0 -1094
- package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
- package/core/.system/kenaz/README.md +0 -787
- package/core/.system/memory/README.md +0 -719
- package/core/.system/pipeline/README.md +0 -712
- package/core/.system/rule/README.md +0 -794
- package/core/.system/sunny/README.md +0 -476
- package/core/.system/sunny/RULES.json +0 -89
- package/core/.system/sunny/knowledge/INDEX.md +0 -37
- package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
- package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
- package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
- package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
- package/core/.system/sunny/teammates/README.md +0 -107
- package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
- package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
- package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
- package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
- package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
- package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
- package/core/.system/sunny/tools.json +0 -101
- package/core/dev/scripts/cleanup-queue.js +0 -184
- package/core/dev/scripts/cleanup_queue.js +0 -86
- package/core/dev/scripts/legacy/README.md +0 -39
- package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
- package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
- package/core/dev/scripts/matrix/CLI_README.md +0 -214
- package/core/dev/scripts/matrix/README.md +0 -310
- package/core/dev/scripts/matrix/package-lock.json +0 -4266
- package/core/dev/scripts/matrix/package.json +0 -55
- package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
- package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
- package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
- package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
- package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
- package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
- package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
- package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
- package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
- package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
- package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
- package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
- package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
- package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
- package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
- package/core/dev/scripts/matrix/src/index.ts +0 -62
- package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
- package/core/dev/scripts/matrix/src/parser.ts +0 -281
- package/core/dev/scripts/matrix/src/serializer.ts +0 -151
- package/core/dev/scripts/matrix/src/validator.ts +0 -301
- package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
- package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
- package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
- package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
- package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
- package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
- package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
- package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
- package/core/dev/scripts/matrix/tsconfig.json +0 -20
- package/core/dev/scripts/matrix/types/index.d.ts +0 -111
- package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
- package/core/dev/scripts/matrix/types/index.js +0 -8
- package/core/dev/scripts/matrix/types/index.js.map +0 -1
- package/core/dev/scripts/matrix/types/index.ts +0 -124
- package/core/dev/scripts/memory-usage-report.js +0 -152
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
- package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
- package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
- package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
- package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
- package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
- package/core/dev/scripts/validate_pipeline.js +0 -197
- package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
- package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
- package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
- package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
- package/core/plugins/kenaz/commands/strategy.md +0 -141
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .matrix 格式類型定義
|
|
3
|
-
* @version 1.0.0
|
|
4
|
-
* @see dev/design/matrix_format_SYNTAX_BNF.md
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* .matrix 文件完整結構
|
|
9
|
-
*/
|
|
10
|
-
export interface MatrixFile {
|
|
11
|
-
meta: MetaSection;
|
|
12
|
-
index: IndexSection;
|
|
13
|
-
data?: DataSection;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @meta 層:文件元數據
|
|
18
|
-
*/
|
|
19
|
-
export interface MetaSection {
|
|
20
|
-
v: string; // version
|
|
21
|
-
c: string; // category
|
|
22
|
-
t?: string; // timestamp (YYMMDD-HHMM)
|
|
23
|
-
r?: string; // range
|
|
24
|
-
proj?: string; // project
|
|
25
|
-
[key: string]: string | undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @index 層:快速查詢索引
|
|
30
|
-
*/
|
|
31
|
-
export interface IndexSection {
|
|
32
|
-
[key: string]: string | number | boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @data 層:實際數據內容
|
|
37
|
-
*/
|
|
38
|
-
export interface DataSection {
|
|
39
|
-
records: DataRecord[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 單筆數據記錄
|
|
44
|
-
*/
|
|
45
|
-
export interface DataRecord {
|
|
46
|
-
id: string;
|
|
47
|
-
fields: Record<string, any>;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 解析結果
|
|
52
|
-
*/
|
|
53
|
-
export interface ParseResult {
|
|
54
|
-
success: boolean;
|
|
55
|
-
data?: MatrixFile;
|
|
56
|
-
error?: ParseError;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 解析錯誤
|
|
61
|
-
*/
|
|
62
|
-
export interface ParseError {
|
|
63
|
-
code: string; // E001, E002, etc.
|
|
64
|
-
message: string;
|
|
65
|
-
line?: number;
|
|
66
|
-
column?: number;
|
|
67
|
-
expected?: string;
|
|
68
|
-
got?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 驗證結果
|
|
73
|
-
*/
|
|
74
|
-
export interface ValidationResult {
|
|
75
|
-
valid: boolean;
|
|
76
|
-
errors: ParseError[];
|
|
77
|
-
warnings: ParseError[];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 序列化選項
|
|
82
|
-
*/
|
|
83
|
-
export interface SerializeOptions {
|
|
84
|
-
/**
|
|
85
|
-
* 是否美化輸出(添加換行)
|
|
86
|
-
* @default false
|
|
87
|
-
*/
|
|
88
|
-
pretty?: boolean;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 是否包含註釋行
|
|
92
|
-
* @default true
|
|
93
|
-
*/
|
|
94
|
-
includeComment?: boolean;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 註釋內容
|
|
98
|
-
* @default ".matrix v1.0"
|
|
99
|
-
*/
|
|
100
|
-
comment?: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 解析選項
|
|
105
|
-
*/
|
|
106
|
-
export interface ParseOptions {
|
|
107
|
-
/**
|
|
108
|
-
* 是否嚴格模式(遇到錯誤立即拋出)
|
|
109
|
-
* @default true
|
|
110
|
-
*/
|
|
111
|
-
strict?: boolean;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 是否自動修正錯誤
|
|
115
|
-
* @default false
|
|
116
|
-
*/
|
|
117
|
-
autoFix?: boolean;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 是否驗證欄位名稱
|
|
121
|
-
* @default true
|
|
122
|
-
*/
|
|
123
|
-
validateFields?: boolean;
|
|
124
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* memory-usage-report.js — TASK_2024
|
|
4
|
-
*
|
|
5
|
-
* Reads .kenaz/specialist/memory_usage.jsonl (written by memory-guard.js's
|
|
6
|
-
* match()/matchAreas() on real hook invocations, and by memory-guard.js main() on Read
|
|
7
|
-
* for a direct Read of a memory/knowledge-dir file — see memory-guard.js
|
|
8
|
-
* appendUsageLog()) and reports, per memory file:
|
|
9
|
-
* - last used timestamp
|
|
10
|
-
* - counts by kind (guard | area | read)
|
|
11
|
-
* plus a separate list of memory files that were NOT used in the last N
|
|
12
|
-
* days (default 90), with their mtime — candidates for pruning.
|
|
13
|
-
*
|
|
14
|
-
* "Used" here means logged by memory-guard's usage log, not merely present
|
|
15
|
-
* on disk; a file with zero log lines has never fired a guard trigger,
|
|
16
|
-
* been surfaced in an area digest, or been Read directly.
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
* node dev/scripts/memory-usage-report.js [--project-dir=<path>] [--days=90]
|
|
20
|
-
*
|
|
21
|
-
* GEN-008: no hardcoded project path — defaults to CLAUDE_PROJECT_DIR/cwd.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
'use strict';
|
|
25
|
-
|
|
26
|
-
const fs = require('fs');
|
|
27
|
-
const path = require('path');
|
|
28
|
-
const guard = require('../../.claude/hooks/memory-guard');
|
|
29
|
-
|
|
30
|
-
// Index files, not prunable memory entries — excluded from both report sections.
|
|
31
|
-
const INDEX_FILES = new Set(['KNOWLEDGE.md', 'MEMORY.md']);
|
|
32
|
-
|
|
33
|
-
function parseArgs(argv) {
|
|
34
|
-
const out = { days: 90, projectDir: process.env.CLAUDE_PROJECT_DIR || process.cwd() };
|
|
35
|
-
for (const a of argv) {
|
|
36
|
-
const dMatch = a.match(/^--days=(\d+)$/);
|
|
37
|
-
if (dMatch) out.days = parseInt(dMatch[1], 10);
|
|
38
|
-
const pMatch = a.match(/^--project-dir=(.+)$/);
|
|
39
|
-
if (pMatch) out.projectDir = path.resolve(pMatch[1]);
|
|
40
|
-
}
|
|
41
|
-
return out;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Read every parseable line of the usage log; a malformed line is skipped, never fatal. */
|
|
45
|
-
function readUsageLog(usageLogPath) {
|
|
46
|
-
let lines;
|
|
47
|
-
try {
|
|
48
|
-
lines = fs.readFileSync(usageLogPath, 'utf8').split(/\r?\n/).filter(Boolean);
|
|
49
|
-
} catch {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
const records = [];
|
|
53
|
-
for (const line of lines) {
|
|
54
|
-
try {
|
|
55
|
-
const r = JSON.parse(line);
|
|
56
|
-
if (r && typeof r === 'object' && r.file) records.push(r);
|
|
57
|
-
} catch {
|
|
58
|
-
/* skip malformed line */
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return records;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Every .md memory file across the project's source dirs (memory dir + active knowledge dir), excluding index files. */
|
|
65
|
-
function listMemoryFiles(projectDir) {
|
|
66
|
-
const files = new Map(); // absPath -> { name, dir, mtimeMs }
|
|
67
|
-
for (const dir of guard.defaultSourceDirs(projectDir)) {
|
|
68
|
-
let entries;
|
|
69
|
-
try {
|
|
70
|
-
entries = fs.readdirSync(dir);
|
|
71
|
-
} catch {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
for (const name of entries) {
|
|
75
|
-
if (!name.endsWith('.md') || INDEX_FILES.has(name)) continue;
|
|
76
|
-
const absPath = path.join(dir, name);
|
|
77
|
-
let mtimeMs = 0;
|
|
78
|
-
try {
|
|
79
|
-
mtimeMs = fs.statSync(absPath).mtimeMs;
|
|
80
|
-
} catch {
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
files.set(absPath, { name, dir, mtimeMs });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return files;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function formatDate(ms) {
|
|
90
|
-
if (!ms) return '(never)';
|
|
91
|
-
return new Date(ms).toISOString();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function main() {
|
|
95
|
-
const { days, projectDir } = parseArgs(process.argv.slice(2));
|
|
96
|
-
const usageLogPath = guard.defaultUsageLogPath(projectDir);
|
|
97
|
-
const records = readUsageLog(usageLogPath);
|
|
98
|
-
const memoryFiles = listMemoryFiles(projectDir);
|
|
99
|
-
|
|
100
|
-
console.log(`Usage log: ${usageLogPath} (${records.length} record(s))`);
|
|
101
|
-
console.log(`Memory files found: ${memoryFiles.size}`);
|
|
102
|
-
|
|
103
|
-
// Aggregate by basename — the same filename may exist under multiple
|
|
104
|
-
// source dirs (memory dir vs. a sub-project's .kenaz/knowledge dir), and
|
|
105
|
-
// the usage log only carries the basename, not the full path.
|
|
106
|
-
const usageByFile = new Map(); // name -> { lastUsedMs, counts: { guard, area, read } }
|
|
107
|
-
for (const r of records) {
|
|
108
|
-
let entry = usageByFile.get(r.file);
|
|
109
|
-
if (!entry) {
|
|
110
|
-
entry = { lastUsedMs: 0, counts: { guard: 0, area: 0, read: 0 } };
|
|
111
|
-
usageByFile.set(r.file, entry);
|
|
112
|
-
}
|
|
113
|
-
const ts = Date.parse(r.ts);
|
|
114
|
-
if (!Number.isNaN(ts) && ts > entry.lastUsedMs) entry.lastUsedMs = ts;
|
|
115
|
-
if (r.kind && Object.prototype.hasOwnProperty.call(entry.counts, r.kind)) {
|
|
116
|
-
entry.counts[r.kind]++;
|
|
117
|
-
} else if (r.kind) {
|
|
118
|
-
entry.counts[r.kind] = (entry.counts[r.kind] || 0) + 1;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
console.log('\nPer-file usage (last used, counts by kind):');
|
|
123
|
-
const usedRows = Array.from(usageByFile.entries()).sort((a, b) => b[1].lastUsedMs - a[1].lastUsedMs);
|
|
124
|
-
if (!usedRows.length) console.log(' (no usage recorded yet)');
|
|
125
|
-
for (const [name, entry] of usedRows) {
|
|
126
|
-
const countsStr = Object.entries(entry.counts)
|
|
127
|
-
.filter(([, n]) => n > 0)
|
|
128
|
-
.map(([k, n]) => `${k}=${n}`)
|
|
129
|
-
.join(' ');
|
|
130
|
-
console.log(` ${name} — last used: ${formatDate(entry.lastUsedMs)} — ${countsStr}`);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const cutoffMs = Date.now() - days * 24 * 60 * 60 * 1000;
|
|
134
|
-
const unused = [];
|
|
135
|
-
for (const [absPath, info] of memoryFiles) {
|
|
136
|
-
const usage = usageByFile.get(info.name);
|
|
137
|
-
const lastUsedMs = usage ? usage.lastUsedMs : 0;
|
|
138
|
-
if (lastUsedMs < cutoffMs) {
|
|
139
|
-
unused.push({ name: info.name, absPath, mtimeMs: info.mtimeMs, lastUsedMs });
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
unused.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
143
|
-
|
|
144
|
-
console.log(`\nNever used in the last ${days} day(s) (${unused.length} file(s), oldest mtime first):`);
|
|
145
|
-
if (!unused.length) console.log(' (none)');
|
|
146
|
-
for (const u of unused) {
|
|
147
|
-
const lastUsedStr = u.lastUsedMs ? `last used ${formatDate(u.lastUsedMs)}` : 'never used';
|
|
148
|
-
console.log(` ${u.name} — mtime: ${formatDate(u.mtimeMs)} — ${lastUsedStr}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
main();
|