cclaw-cli 7.7.1 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +211 -134
  2. package/dist/artifact-frontmatter.d.ts +51 -0
  3. package/dist/artifact-frontmatter.js +131 -0
  4. package/dist/artifact-paths.d.ts +7 -27
  5. package/dist/artifact-paths.js +20 -249
  6. package/dist/cancel.d.ts +16 -0
  7. package/dist/cancel.js +66 -0
  8. package/dist/cli.d.ts +2 -27
  9. package/dist/cli.js +107 -511
  10. package/dist/compound.d.ts +26 -0
  11. package/dist/compound.js +96 -0
  12. package/dist/config.d.ts +14 -51
  13. package/dist/config.js +23 -359
  14. package/dist/constants.d.ts +11 -18
  15. package/dist/constants.js +19 -106
  16. package/dist/content/antipatterns.d.ts +1 -0
  17. package/dist/content/antipatterns.js +109 -0
  18. package/dist/content/artifact-templates.d.ts +10 -0
  19. package/dist/content/artifact-templates.js +550 -0
  20. package/dist/content/cancel-command.d.ts +2 -2
  21. package/dist/content/cancel-command.js +25 -17
  22. package/dist/content/core-agents.d.ts +9 -233
  23. package/dist/content/core-agents.js +39 -768
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -134
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/harness-prompt.d.ts +26 -0
  73. package/dist/harness-prompt.js +142 -0
  74. package/dist/install.d.ts +35 -15
  75. package/dist/install.js +238 -1347
  76. package/dist/knowledge-store.d.ts +19 -163
  77. package/dist/knowledge-store.js +56 -590
  78. package/dist/logger.d.ts +8 -3
  79. package/dist/logger.js +13 -4
  80. package/dist/orchestrator-routing.d.ts +29 -0
  81. package/dist/orchestrator-routing.js +156 -0
  82. package/dist/run-persistence.d.ts +7 -118
  83. package/dist/run-persistence.js +29 -845
  84. package/dist/runtime/run-hook.entry.d.ts +1 -3
  85. package/dist/runtime/run-hook.entry.js +19 -4
  86. package/dist/runtime/run-hook.mjs +13 -1024
  87. package/dist/types.d.ts +25 -261
  88. package/dist/types.js +8 -36
  89. package/package.json +6 -3
  90. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  91. package/dist/artifact-linter/brainstorm.js +0 -353
  92. package/dist/artifact-linter/design.d.ts +0 -18
  93. package/dist/artifact-linter/design.js +0 -444
  94. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  95. package/dist/artifact-linter/findings-dedup.js +0 -232
  96. package/dist/artifact-linter/plan.d.ts +0 -2
  97. package/dist/artifact-linter/plan.js +0 -826
  98. package/dist/artifact-linter/review-army.d.ts +0 -49
  99. package/dist/artifact-linter/review-army.js +0 -520
  100. package/dist/artifact-linter/review.d.ts +0 -2
  101. package/dist/artifact-linter/review.js +0 -113
  102. package/dist/artifact-linter/scope.d.ts +0 -2
  103. package/dist/artifact-linter/scope.js +0 -158
  104. package/dist/artifact-linter/shared.d.ts +0 -637
  105. package/dist/artifact-linter/shared.js +0 -2163
  106. package/dist/artifact-linter/ship.d.ts +0 -2
  107. package/dist/artifact-linter/ship.js +0 -250
  108. package/dist/artifact-linter/spec.d.ts +0 -2
  109. package/dist/artifact-linter/spec.js +0 -176
  110. package/dist/artifact-linter/tdd.d.ts +0 -118
  111. package/dist/artifact-linter/tdd.js +0 -1404
  112. package/dist/artifact-linter.d.ts +0 -15
  113. package/dist/artifact-linter.js +0 -517
  114. package/dist/codex-feature-flag.d.ts +0 -58
  115. package/dist/codex-feature-flag.js +0 -193
  116. package/dist/content/closeout-guidance.d.ts +0 -14
  117. package/dist/content/closeout-guidance.js +0 -44
  118. package/dist/content/diff-command.d.ts +0 -1
  119. package/dist/content/diff-command.js +0 -43
  120. package/dist/content/harness-doc.d.ts +0 -1
  121. package/dist/content/harness-doc.js +0 -65
  122. package/dist/content/hook-events.d.ts +0 -9
  123. package/dist/content/hook-events.js +0 -23
  124. package/dist/content/hook-manifest.d.ts +0 -81
  125. package/dist/content/hook-manifest.js +0 -156
  126. package/dist/content/hooks.d.ts +0 -11
  127. package/dist/content/hooks.js +0 -1972
  128. package/dist/content/idea.d.ts +0 -60
  129. package/dist/content/idea.js +0 -416
  130. package/dist/content/language-policy.d.ts +0 -2
  131. package/dist/content/language-policy.js +0 -13
  132. package/dist/content/learnings.d.ts +0 -6
  133. package/dist/content/learnings.js +0 -141
  134. package/dist/content/observe.d.ts +0 -19
  135. package/dist/content/observe.js +0 -86
  136. package/dist/content/opencode-plugin.d.ts +0 -1
  137. package/dist/content/opencode-plugin.js +0 -635
  138. package/dist/content/review-prompts.d.ts +0 -1
  139. package/dist/content/review-prompts.js +0 -104
  140. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  141. package/dist/content/runtime-shared-snippets.js +0 -80
  142. package/dist/content/session-hooks.d.ts +0 -7
  143. package/dist/content/session-hooks.js +0 -107
  144. package/dist/content/skills-elicitation.d.ts +0 -1
  145. package/dist/content/skills-elicitation.js +0 -167
  146. package/dist/content/stage-command.d.ts +0 -2
  147. package/dist/content/stage-command.js +0 -17
  148. package/dist/content/stage-schema.d.ts +0 -117
  149. package/dist/content/stage-schema.js +0 -955
  150. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  151. package/dist/content/stages/_lint-metadata/index.js +0 -97
  152. package/dist/content/stages/brainstorm.d.ts +0 -2
  153. package/dist/content/stages/brainstorm.js +0 -184
  154. package/dist/content/stages/design.d.ts +0 -2
  155. package/dist/content/stages/design.js +0 -288
  156. package/dist/content/stages/index.d.ts +0 -8
  157. package/dist/content/stages/index.js +0 -11
  158. package/dist/content/stages/plan.d.ts +0 -2
  159. package/dist/content/stages/plan.js +0 -191
  160. package/dist/content/stages/review.d.ts +0 -2
  161. package/dist/content/stages/review.js +0 -240
  162. package/dist/content/stages/schema-types.d.ts +0 -203
  163. package/dist/content/stages/schema-types.js +0 -1
  164. package/dist/content/stages/scope.d.ts +0 -2
  165. package/dist/content/stages/scope.js +0 -254
  166. package/dist/content/stages/ship.d.ts +0 -2
  167. package/dist/content/stages/ship.js +0 -159
  168. package/dist/content/stages/spec.d.ts +0 -2
  169. package/dist/content/stages/spec.js +0 -170
  170. package/dist/content/stages/tdd.d.ts +0 -4
  171. package/dist/content/stages/tdd.js +0 -273
  172. package/dist/content/state-contracts.d.ts +0 -1
  173. package/dist/content/state-contracts.js +0 -63
  174. package/dist/content/status-command.d.ts +0 -4
  175. package/dist/content/status-command.js +0 -109
  176. package/dist/content/subagent-context-skills.d.ts +0 -4
  177. package/dist/content/subagent-context-skills.js +0 -279
  178. package/dist/content/subagents.d.ts +0 -3
  179. package/dist/content/subagents.js +0 -997
  180. package/dist/content/templates.d.ts +0 -26
  181. package/dist/content/templates.js +0 -1692
  182. package/dist/content/track-render-context.d.ts +0 -18
  183. package/dist/content/track-render-context.js +0 -53
  184. package/dist/content/tree-command.d.ts +0 -1
  185. package/dist/content/tree-command.js +0 -64
  186. package/dist/content/utility-skills.d.ts +0 -30
  187. package/dist/content/utility-skills.js +0 -160
  188. package/dist/content/view-command.d.ts +0 -2
  189. package/dist/content/view-command.js +0 -92
  190. package/dist/delegation.d.ts +0 -649
  191. package/dist/delegation.js +0 -1539
  192. package/dist/early-loop.d.ts +0 -70
  193. package/dist/early-loop.js +0 -302
  194. package/dist/execution-topology.d.ts +0 -44
  195. package/dist/execution-topology.js +0 -95
  196. package/dist/gate-evidence.d.ts +0 -85
  197. package/dist/gate-evidence.js +0 -631
  198. package/dist/harness-adapters.d.ts +0 -151
  199. package/dist/harness-adapters.js +0 -756
  200. package/dist/harness-selection.d.ts +0 -31
  201. package/dist/harness-selection.js +0 -214
  202. package/dist/hook-schema.d.ts +0 -6
  203. package/dist/hook-schema.js +0 -114
  204. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  205. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  206. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  207. package/dist/init-detect.d.ts +0 -2
  208. package/dist/init-detect.js +0 -50
  209. package/dist/internal/advance-stage/advance.d.ts +0 -89
  210. package/dist/internal/advance-stage/advance.js +0 -655
  211. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  212. package/dist/internal/advance-stage/cancel-run.js +0 -19
  213. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  214. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  215. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  216. package/dist/internal/advance-stage/helpers.js +0 -145
  217. package/dist/internal/advance-stage/hook.d.ts +0 -8
  218. package/dist/internal/advance-stage/hook.js +0 -40
  219. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  220. package/dist/internal/advance-stage/parsers.js +0 -357
  221. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  222. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  223. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  224. package/dist/internal/advance-stage/review-loop.js +0 -199
  225. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  226. package/dist/internal/advance-stage/rewind.js +0 -108
  227. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  228. package/dist/internal/advance-stage/start-flow.js +0 -241
  229. package/dist/internal/advance-stage/verify.d.ts +0 -21
  230. package/dist/internal/advance-stage/verify.js +0 -185
  231. package/dist/internal/advance-stage.d.ts +0 -7
  232. package/dist/internal/advance-stage.js +0 -138
  233. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  234. package/dist/internal/cohesion-contract-stub.js +0 -148
  235. package/dist/internal/compound-readiness.d.ts +0 -23
  236. package/dist/internal/compound-readiness.js +0 -102
  237. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  238. package/dist/internal/detect-public-api-changes.js +0 -45
  239. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  240. package/dist/internal/detect-supply-chain-changes.js +0 -138
  241. package/dist/internal/early-loop-status.d.ts +0 -7
  242. package/dist/internal/early-loop-status.js +0 -93
  243. package/dist/internal/envelope-validate.d.ts +0 -7
  244. package/dist/internal/envelope-validate.js +0 -66
  245. package/dist/internal/flow-state-repair.d.ts +0 -20
  246. package/dist/internal/flow-state-repair.js +0 -104
  247. package/dist/internal/plan-split-waves.d.ts +0 -190
  248. package/dist/internal/plan-split-waves.js +0 -764
  249. package/dist/internal/runtime-integrity.d.ts +0 -7
  250. package/dist/internal/runtime-integrity.js +0 -268
  251. package/dist/internal/slice-commit.d.ts +0 -7
  252. package/dist/internal/slice-commit.js +0 -619
  253. package/dist/internal/tdd-loop-status.d.ts +0 -14
  254. package/dist/internal/tdd-loop-status.js +0 -68
  255. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  256. package/dist/internal/tdd-red-evidence.js +0 -153
  257. package/dist/internal/waiver-grant.d.ts +0 -62
  258. package/dist/internal/waiver-grant.js +0 -294
  259. package/dist/internal/wave-status.d.ts +0 -74
  260. package/dist/internal/wave-status.js +0 -506
  261. package/dist/managed-resources.d.ts +0 -53
  262. package/dist/managed-resources.js +0 -313
  263. package/dist/policy.d.ts +0 -10
  264. package/dist/policy.js +0 -167
  265. package/dist/retro-gate.d.ts +0 -9
  266. package/dist/retro-gate.js +0 -47
  267. package/dist/run-archive.d.ts +0 -61
  268. package/dist/run-archive.js +0 -391
  269. package/dist/runs.d.ts +0 -2
  270. package/dist/runs.js +0 -2
  271. package/dist/stack-detection.d.ts +0 -116
  272. package/dist/stack-detection.js +0 -489
  273. package/dist/streaming/event-stream.d.ts +0 -31
  274. package/dist/streaming/event-stream.js +0 -114
  275. package/dist/tdd-cycle.d.ts +0 -107
  276. package/dist/tdd-cycle.js +0 -289
  277. package/dist/tdd-verification-evidence.d.ts +0 -17
  278. package/dist/tdd-verification-evidence.js +0 -122
  279. package/dist/track-heuristics.d.ts +0 -27
  280. package/dist/track-heuristics.js +0 -154
  281. package/dist/util/slice-id.d.ts +0 -58
  282. package/dist/util/slice-id.js +0 -89
  283. package/dist/worktree-manager.d.ts +0 -20
  284. package/dist/worktree-manager.js +0 -108
@@ -1,313 +0,0 @@
1
- import crypto from "node:crypto";
2
- import fs from "node:fs/promises";
3
- import path from "node:path";
4
- import { CCLAW_VERSION, RUNTIME_ROOT } from "./constants.js";
5
- import { HARNESS_IDS } from "./types.js";
6
- export const MANAGED_RESOURCE_MANIFEST_REL_PATH = `${RUNTIME_ROOT}/state/managed-resources.json`;
7
- const MANAGED_RESOURCE_HARNESSES = new Set(["core", ...HARNESS_IDS]);
8
- const SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/iu;
9
- let activeSession = null;
10
- function sha256(content) {
11
- return crypto.createHash("sha256").update(content).digest("hex");
12
- }
13
- function normalizeRelPath(projectRoot, filePath) {
14
- const rel = path.relative(projectRoot, filePath).replace(/\\/gu, "/");
15
- if (rel.startsWith("../") || rel === ".." || path.isAbsolute(rel))
16
- return null;
17
- return rel;
18
- }
19
- async function exists(filePath) {
20
- try {
21
- await fs.access(filePath);
22
- return true;
23
- }
24
- catch {
25
- return false;
26
- }
27
- }
28
- async function ensureDir(dirPath) {
29
- await fs.mkdir(dirPath, { recursive: true });
30
- }
31
- async function atomicWrite(filePath, content, options = {}) {
32
- await ensureDir(path.dirname(filePath));
33
- const tempPath = path.join(path.dirname(filePath), `.${path.basename(filePath)}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`);
34
- await fs.writeFile(tempPath, content, {
35
- encoding: "utf8",
36
- ...(options.mode !== undefined ? { mode: options.mode } : {})
37
- });
38
- await fs.rename(tempPath, filePath);
39
- if (options.mode !== undefined) {
40
- await fs.chmod(filePath, options.mode).catch(() => undefined);
41
- }
42
- }
43
- function inferHarness(relPath) {
44
- if (relPath.startsWith(".claude/"))
45
- return "claude";
46
- if (relPath.startsWith(".cursor/"))
47
- return "cursor";
48
- if (relPath.startsWith(".opencode/"))
49
- return "opencode";
50
- if (relPath.startsWith(".codex/") || relPath.startsWith(".agents/skills/"))
51
- return "codex";
52
- return "core";
53
- }
54
- export function isManagedGeneratedPath(relPath) {
55
- if (relPath === MANAGED_RESOURCE_MANIFEST_REL_PATH)
56
- return false;
57
- if (relPath === `${RUNTIME_ROOT}/config.yaml`)
58
- return false;
59
- if (relPath === `${RUNTIME_ROOT}/knowledge.jsonl`)
60
- return false;
61
- if (relPath.startsWith(`${RUNTIME_ROOT}/artifacts/`))
62
- return false;
63
- if (relPath.startsWith(`${RUNTIME_ROOT}/worktrees/`))
64
- return false;
65
- if (relPath.startsWith(`${RUNTIME_ROOT}/archive/`))
66
- return false;
67
- if (relPath === `${RUNTIME_ROOT}/state/flow-state.json`)
68
- return false;
69
- if (relPath === `${RUNTIME_ROOT}/state/.init-in-progress`)
70
- return false;
71
- if (relPath.startsWith(`${RUNTIME_ROOT}/state/upgrade-backups/`))
72
- return false;
73
- if (relPath.startsWith(`${RUNTIME_ROOT}/state/sync-backups/`))
74
- return false;
75
- if (relPath === "AGENTS.md" || relPath === "CLAUDE.md")
76
- return true;
77
- if (relPath === `${RUNTIME_ROOT}/state/iron-laws.json`)
78
- return true;
79
- for (const prefix of [
80
- `${RUNTIME_ROOT}/commands/`,
81
- `${RUNTIME_ROOT}/skills/`,
82
- `${RUNTIME_ROOT}/templates/`,
83
- `${RUNTIME_ROOT}/rules/`,
84
- `${RUNTIME_ROOT}/agents/`,
85
- `${RUNTIME_ROOT}/hooks/`,
86
- ".claude/commands/",
87
- ".cursor/commands/",
88
- ".opencode/commands/",
89
- ".opencode/agents/",
90
- ".codex/agents/",
91
- ".agents/skills/"
92
- ]) {
93
- if (relPath.startsWith(prefix))
94
- return true;
95
- }
96
- return relPath === ".claude/hooks/hooks.json" ||
97
- relPath === ".cursor/hooks.json" ||
98
- relPath === ".cursor/rules/cclaw-workflow.mdc" ||
99
- relPath === ".codex/hooks.json" ||
100
- relPath === ".opencode/plugins/cclaw-plugin.mjs";
101
- }
102
- function validationIssue(index, field, message, pathValue) {
103
- return {
104
- ...(index !== undefined ? { index } : {}),
105
- ...(typeof pathValue === "string" ? { path: pathValue } : {}),
106
- field,
107
- message
108
- };
109
- }
110
- function validateSha256(value) {
111
- return typeof value === "string" && SHA256_HEX_PATTERN.test(value);
112
- }
113
- export function validateManagedResourceEntry(value, index) {
114
- const issues = [];
115
- if (!value || typeof value !== "object" || Array.isArray(value)) {
116
- return [validationIssue(index, "entry", "entry must be an object")];
117
- }
118
- const entry = value;
119
- if (typeof entry.path !== "string" || entry.path.trim().length === 0) {
120
- issues.push(validationIssue(index, "path", "path must be a non-empty string", entry.path));
121
- }
122
- else if (entry.path.startsWith("../") || entry.path === ".." || path.isAbsolute(entry.path)) {
123
- issues.push(validationIssue(index, "path", "path must be project-relative", entry.path));
124
- }
125
- else if (!isManagedGeneratedPath(entry.path)) {
126
- issues.push(validationIssue(index, "path", "path must be a known generated cclaw surface", entry.path));
127
- }
128
- if (!validateSha256(entry.sha256)) {
129
- issues.push(validationIssue(index, "sha256", "sha256 must be a 64-character hex digest", entry.path));
130
- }
131
- if (entry.owner !== "cclaw") {
132
- issues.push(validationIssue(index, "owner", 'owner must be "cclaw"', entry.path));
133
- }
134
- if (typeof entry.harness !== "string" || !MANAGED_RESOURCE_HARNESSES.has(entry.harness)) {
135
- issues.push(validationIssue(index, "harness", `harness must be one of: core, ${HARNESS_IDS.join(", ")}`, entry.path));
136
- }
137
- if (typeof entry.packageVersion !== "string" || entry.packageVersion.trim().length === 0) {
138
- issues.push(validationIssue(index, "packageVersion", "packageVersion must be a non-empty string", entry.path));
139
- }
140
- if (typeof entry.prunable !== "boolean") {
141
- issues.push(validationIssue(index, "prunable", "prunable must be a boolean", entry.path));
142
- }
143
- if (typeof entry.safeToOverwrite !== "boolean") {
144
- issues.push(validationIssue(index, "safeToOverwrite", "safeToOverwrite must be a boolean", entry.path));
145
- }
146
- if (typeof entry.updatedAt !== "string" || entry.updatedAt.trim().length === 0) {
147
- issues.push(validationIssue(index, "updatedAt", "updatedAt must be a non-empty string", entry.path));
148
- }
149
- if (entry.lastBackupPath !== undefined && (typeof entry.lastBackupPath !== "string" || entry.lastBackupPath.trim().length === 0)) {
150
- issues.push(validationIssue(index, "lastBackupPath", "lastBackupPath must be a non-empty string when present", entry.path));
151
- }
152
- if (entry.previousSha256 !== undefined && !validateSha256(entry.previousSha256)) {
153
- issues.push(validationIssue(index, "previousSha256", "previousSha256 must be a 64-character hex digest when present", entry.path));
154
- }
155
- return issues;
156
- }
157
- export function validateManagedResourceManifest(value) {
158
- const issues = [];
159
- if (!value || typeof value !== "object" || Array.isArray(value)) {
160
- return [validationIssue(undefined, "manifest", "manifest must be an object")];
161
- }
162
- const manifest = value;
163
- if (manifest.version !== 1) {
164
- issues.push(validationIssue(undefined, "version", "version must be 1"));
165
- }
166
- if (typeof manifest.generatedAt !== "string" || manifest.generatedAt.trim().length === 0) {
167
- issues.push(validationIssue(undefined, "generatedAt", "generatedAt must be a non-empty string"));
168
- }
169
- if (typeof manifest.packageVersion !== "string" || manifest.packageVersion.trim().length === 0) {
170
- issues.push(validationIssue(undefined, "packageVersion", "packageVersion must be a non-empty string"));
171
- }
172
- if (!Array.isArray(manifest.resources)) {
173
- issues.push(validationIssue(undefined, "resources", "resources must be an array"));
174
- return issues;
175
- }
176
- manifest.resources.forEach((entry, index) => {
177
- issues.push(...validateManagedResourceEntry(entry, index));
178
- });
179
- return issues;
180
- }
181
- export function isValidManagedResourceEntry(value) {
182
- return validateManagedResourceEntry(value).length === 0;
183
- }
184
- export async function readManagedResourceManifest(projectRoot) {
185
- const manifestPath = path.join(projectRoot, MANAGED_RESOURCE_MANIFEST_REL_PATH);
186
- if (!(await exists(manifestPath)))
187
- return null;
188
- const parsed = JSON.parse(await fs.readFile(manifestPath, "utf8"));
189
- if (parsed.version !== 1 || !Array.isArray(parsed.resources))
190
- return null;
191
- const resources = parsed.resources.filter(isValidManagedResourceEntry);
192
- return {
193
- version: 1,
194
- generatedAt: typeof parsed.generatedAt === "string" ? parsed.generatedAt : new Date(0).toISOString(),
195
- packageVersion: typeof parsed.packageVersion === "string" ? parsed.packageVersion : "unknown",
196
- resources
197
- };
198
- }
199
- export class ManagedResourceSession {
200
- projectRoot;
201
- operation;
202
- timestamp;
203
- previous = new Map();
204
- touched = new Map();
205
- constructor(options, previous) {
206
- this.projectRoot = options.projectRoot;
207
- this.operation = options.operation;
208
- this.timestamp = new Date().toISOString().replace(/[:.]/gu, "-");
209
- for (const entry of previous?.resources ?? []) {
210
- this.previous.set(entry.path, entry);
211
- }
212
- }
213
- static async create(options) {
214
- const manifestPath = path.join(options.projectRoot, MANAGED_RESOURCE_MANIFEST_REL_PATH);
215
- let previous = null;
216
- if (await exists(manifestPath)) {
217
- let raw;
218
- try {
219
- raw = JSON.parse(await fs.readFile(manifestPath, "utf8"));
220
- }
221
- catch (error) {
222
- throw new Error(`[sync fail-fast] Managed resource manifest is corrupt JSON (${MANAGED_RESOURCE_MANIFEST_REL_PATH}): ${error instanceof Error ? error.message : String(error)}. Fix/remove the manifest and rerun \`npx cclaw-cli sync\`.`);
223
- }
224
- const issues = validateManagedResourceManifest(raw);
225
- if (issues.length > 0) {
226
- const detail = issues.slice(0, 12)
227
- .map((issue) => {
228
- const scope = issue.path ?? (issue.index !== undefined ? `resources[${issue.index}]` : "manifest");
229
- return `${scope}.${issue.field}: ${issue.message}`;
230
- })
231
- .join("; ");
232
- throw new Error(`[sync fail-fast] Managed resource manifest is malformed (${MANAGED_RESOURCE_MANIFEST_REL_PATH}): ${detail}. ` +
233
- `Fix/remove the manifest and rerun \`npx cclaw-cli sync\`.`);
234
- }
235
- previous = await readManagedResourceManifest(options.projectRoot).catch(() => null);
236
- }
237
- return new ManagedResourceSession(options, previous);
238
- }
239
- shouldManage(filePath) {
240
- const rel = normalizeRelPath(this.projectRoot, filePath);
241
- return rel !== null && isManagedGeneratedPath(rel);
242
- }
243
- async writeFileSafe(filePath, content, options = {}) {
244
- const rel = normalizeRelPath(this.projectRoot, filePath);
245
- if (rel === null || !isManagedGeneratedPath(rel)) {
246
- await atomicWrite(filePath, content, options);
247
- return;
248
- }
249
- const nextHash = sha256(content);
250
- const previous = this.previous.get(rel);
251
- let previousSha256;
252
- let lastBackupPath;
253
- if (await exists(filePath)) {
254
- const current = await fs.readFile(filePath);
255
- const currentHash = sha256(current);
256
- previousSha256 = currentHash;
257
- const knownPrevious = previous?.sha256;
258
- if (currentHash !== nextHash && (knownPrevious === undefined || currentHash !== knownPrevious)) {
259
- const backupRoot = path.join(this.projectRoot, RUNTIME_ROOT, "state", this.operation === "upgrade" ? "upgrade-backups" : "sync-backups", this.timestamp);
260
- const backupPath = path.join(backupRoot, rel);
261
- await ensureDir(path.dirname(backupPath));
262
- await fs.copyFile(filePath, backupPath);
263
- lastBackupPath = normalizeRelPath(this.projectRoot, backupPath) ?? undefined;
264
- }
265
- }
266
- await atomicWrite(filePath, content, options);
267
- this.touched.set(rel, {
268
- path: rel,
269
- sha256: nextHash,
270
- owner: "cclaw",
271
- harness: inferHarness(rel),
272
- packageVersion: CCLAW_VERSION,
273
- prunable: true,
274
- safeToOverwrite: true,
275
- updatedAt: new Date().toISOString(),
276
- ...(lastBackupPath ? { lastBackupPath } : {}),
277
- ...(previousSha256 && previousSha256 !== nextHash ? { previousSha256 } : {})
278
- });
279
- }
280
- async commit() {
281
- const resourcesByPath = new Map(this.previous);
282
- for (const [rel, entry] of this.touched) {
283
- resourcesByPath.set(rel, entry);
284
- }
285
- const resources = [];
286
- for (const entry of resourcesByPath.values()) {
287
- if (await exists(path.join(this.projectRoot, entry.path))) {
288
- resources.push(entry);
289
- }
290
- }
291
- const manifest = {
292
- version: 1,
293
- generatedAt: new Date().toISOString(),
294
- packageVersion: CCLAW_VERSION,
295
- resources: resources.sort((a, b) => a.path.localeCompare(b.path))
296
- };
297
- await atomicWrite(path.join(this.projectRoot, MANAGED_RESOURCE_MANIFEST_REL_PATH), `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
298
- return manifest;
299
- }
300
- }
301
- export function getActiveManagedResourceSession() {
302
- return activeSession;
303
- }
304
- export function setActiveManagedResourceSession(session) {
305
- activeSession = session;
306
- }
307
- export function isManagedResourcePath(projectRoot, filePath) {
308
- const rel = normalizeRelPath(projectRoot, filePath);
309
- return rel !== null && isManagedGeneratedPath(rel);
310
- }
311
- export function hashManagedResourceContent(content) {
312
- return sha256(content);
313
- }
package/dist/policy.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { HarnessId } from "./types.js";
2
- export interface PolicyCheck {
3
- name: string;
4
- ok: boolean;
5
- details: string;
6
- }
7
- export interface PolicyOptions {
8
- harnesses?: HarnessId[];
9
- }
10
- export declare function policyChecks(projectRoot: string, options?: PolicyOptions): Promise<PolicyCheck[]>;
package/dist/policy.js DELETED
@@ -1,167 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { RUNTIME_ROOT } from "./constants.js";
4
- import { FLOW_STAGES } from "./types.js";
5
- import { stageSchema } from "./content/stage-schema.js";
6
- import { stageSkillFolder } from "./content/skills.js";
7
- import { exists } from "./fs-utils.js";
8
- const POLICY_RULES = [];
9
- const ALL_HARNESSES = ["claude", "cursor", "opencode", "codex"];
10
- export async function policyChecks(projectRoot, options = {}) {
11
- const checks = [];
12
- const rules = [...POLICY_RULES];
13
- const activeHarnesses = new Set(options.harnesses && options.harnesses.length > 0 ? options.harnesses : ALL_HARNESSES);
14
- for (const stage of FLOW_STAGES) {
15
- const folder = stageSkillFolder(stage);
16
- const schema = stageSchema(stage);
17
- const skillFile = `${RUNTIME_ROOT}/skills/${folder}/SKILL.md`;
18
- // --- skill mandatory sections ---
19
- for (const heading of [
20
- "## Process",
21
- "## Exit Criteria",
22
- "## Interaction Protocol",
23
- "## Anti-Patterns & Red Flags",
24
- "## HARD-GATE",
25
- "## Checklist",
26
- "## Context Loading",
27
- "## Automatic Subagent Dispatch",
28
- "## Cross-Stage Traceability",
29
- "## Artifact Validation",
30
- "## Completion Parameters",
31
- "## Shared Stage Guidance"
32
- ]) {
33
- rules.push({
34
- filePath: skillFile,
35
- needle: heading,
36
- name: `skill:${stage}:section:${heading.replace(/^## /, "").toLowerCase().replace(/[^a-z0-9]+/g, "_")}`
37
- });
38
- }
39
- // --- gate IDs in skills ---
40
- for (const gate of schema.requiredGates) {
41
- rules.push({
42
- filePath: skillFile,
43
- needle: `\`${gate.id}\``,
44
- name: `skill:${stage}:gate:${gate.id}`
45
- });
46
- }
47
- // --- verification section for build/review/ship skills ---
48
- if (["tdd", "review", "ship"].includes(stage)) {
49
- rules.push({
50
- filePath: skillFile,
51
- needle: "## Verification Before Completion",
52
- name: `skill:${stage}:section:verification_before_completion`
53
- });
54
- }
55
- }
56
- // --- utility skill checks ---
57
- const runtimeFile = (relativePath) => `${RUNTIME_ROOT}/${relativePath}`;
58
- const utilitySkillChecks = [
59
- { file: runtimeFile("skills/learnings/SKILL.md"), needle: "strict JSONL schema", name: "utility_skill:learnings:jsonl_schema" },
60
- { file: runtimeFile("skills/learnings/SKILL.md"), needle: "knowledge.jsonl", name: "utility_skill:learnings:jsonl_store" },
61
- { file: runtimeFile("skills/learnings/SKILL.md"), needle: "type, trigger, action, confidence, stage, origin_stage, frequency, created, first_seen_ts, last_seen_ts, project", name: "utility_skill:learnings:field_order" },
62
- { file: runtimeFile("skills/learnings/SKILL.md"), needle: "## Manual Actions", name: "utility_skill:learnings:manual_actions" },
63
- { file: runtimeFile("skills/learnings/SKILL.md"), needle: "## HARD-GATE", name: "utility_skill:learnings:hard_gate" },
64
- { file: runtimeFile("commands/start.md"), needle: "## Algorithm", name: "utility_command:start:algorithm" },
65
- { file: runtimeFile("commands/idea.md"), needle: "## Algorithm", name: "utility_command:idea:algorithm" },
66
- { file: runtimeFile("skills/flow-idea/SKILL.md"), needle: "## Protocol", name: "utility_skill:idea:protocol" },
67
- { file: runtimeFile("skills/flow-idea/SKILL.md"), needle: "## HARD-GATE", name: "utility_skill:idea:hard_gate" },
68
- { file: runtimeFile("commands/view.md"), needle: "## Routing", name: "utility_command:view:routing" },
69
- { file: runtimeFile("skills/flow-view/SKILL.md"), needle: "## Status Subcommand", name: "utility_skill:view:status_section" },
70
- { file: runtimeFile("skills/flow-view/SKILL.md"), needle: "## Tree Subcommand", name: "utility_skill:view:tree_section" },
71
- { file: runtimeFile("skills/flow-view/SKILL.md"), needle: "## Diff Subcommand", name: "utility_skill:view:diff_section" },
72
- { file: runtimeFile("skills/subagent-dev/SKILL.md"), needle: "## HARD-GATE", name: "utility_skill:sdd:hard_gate" },
73
- { file: runtimeFile("skills/subagent-dev/SKILL.md"), needle: "## Status Contract", name: "utility_skill:sdd:status_contract" },
74
- { file: runtimeFile("skills/subagent-dev/SKILL.md"), needle: "slice-builder", name: "utility_skill:sdd:implementer_template" },
75
- { file: runtimeFile("skills/subagent-dev/SKILL.md"), needle: "## Model & Harness Routing Notes", name: "utility_skill:sdd:routing_notes" },
76
- { file: runtimeFile("skills/parallel-dispatch/SKILL.md"), needle: "## HARD-GATE", name: "utility_skill:parallel:hard_gate" },
77
- { file: runtimeFile("skills/parallel-dispatch/SKILL.md"), needle: "Review Army", name: "utility_skill:parallel:review_army" },
78
- { file: runtimeFile("skills/parallel-dispatch/SKILL.md"), needle: "Reconciliation", name: "utility_skill:parallel:reconciliation" },
79
- { file: runtimeFile("skills/parallel-dispatch/SKILL.md"), needle: "## Model & Harness Routing Notes", name: "utility_skill:parallel:routing_notes" },
80
- { file: runtimeFile("skills/research/repo-scan.md"), needle: "# Repo Scan Playbook", name: "utility_skill:research:repo_scan" },
81
- { file: runtimeFile("skills/research/learnings-lookup.md"), needle: "# Learnings Lookup Playbook", name: "utility_skill:research:learnings_lookup" },
82
- { file: runtimeFile("skills/research/framework-docs-lookup.md"), needle: "# Framework Docs Lookup Playbook", name: "utility_skill:research:framework_docs_lookup" },
83
- { file: runtimeFile("skills/research/best-practices-lookup.md"), needle: "# Best Practices Lookup Playbook", name: "utility_skill:research:best_practices_lookup" },
84
- { file: runtimeFile("skills/research/git-history.md"), needle: "# Git History Playbook", name: "utility_skill:research:git_history" },
85
- { file: runtimeFile("skills/session/SKILL.md"), needle: "## HARD-GATE", name: "utility_skill:session:hard_gate" },
86
- { file: runtimeFile("skills/session/SKILL.md"), needle: "## Session Start Protocol", name: "utility_skill:session:start" },
87
- { file: runtimeFile("skills/session/SKILL.md"), needle: "## Session Stop Protocol", name: "utility_skill:session:stop" },
88
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Routing flow", name: "meta_skill:routing_flow" },
89
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Task classification", name: "meta_skill:task_classification" },
90
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Stage quick map", name: "meta_skill:stage_quick_map" },
91
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Whole flow map", name: "meta_skill:whole_flow_map" },
92
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "post_ship_review -> archive", name: "meta_skill:closeout_chain" },
93
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Contextual Skill Activation", name: "meta_skill:contextual_skills" },
94
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Protocol Behavior", name: "meta_skill:protocol_behavior" },
95
- { file: runtimeFile("skills/using-cclaw/SKILL.md"), needle: "## Failure guardrails", name: "meta_skill:failure_guardrails" },
96
- { file: runtimeFile("skills/session/SKILL.md"), needle: "## Session Resume Protocol", name: "utility_skill:session:resume" },
97
- { file: runtimeFile("skills/brainstorm/SKILL.md"), needle: "## Shared Stage Guidance", name: "stage_skill:shared_guidance_inline" },
98
- { file: runtimeFile("hooks/run-hook.mjs"), needle: "activeRunId", name: "hooks:session_start:active_run" },
99
- { file: runtimeFile("hooks/run-hook.mjs"), needle: "session-start", name: "hooks:session_start:wired" },
100
- { file: runtimeFile("hooks/run-hook.mjs"), needle: "stop-handoff", name: "hooks:stop_handoff:wired" },
101
- { file: runtimeFile("hooks/opencode-plugin.mjs"), needle: "activeRunId", name: "hooks:opencode:active_run" },
102
- { file: runtimeFile("hooks/run-hook.mjs"), needle: "Knowledge digest", name: "hooks:session_start:knowledge_digest" },
103
- { file: runtimeFile("hooks/opencode-plugin.mjs"), needle: "Knowledge digest", name: "hooks:opencode:knowledge_digest" }
104
- ];
105
- if (activeHarnesses.has("opencode")) {
106
- utilitySkillChecks.push({
107
- file: ".opencode/plugins/cclaw-plugin.mjs",
108
- needle: "session-start",
109
- name: "hooks:opencode:deployed_session_start_hook"
110
- });
111
- utilitySkillChecks.push({
112
- file: ".opencode/plugins/cclaw-plugin.mjs",
113
- needle: "stop-handoff",
114
- name: "hooks:opencode:deployed_stop_handoff_hook"
115
- });
116
- }
117
- if (activeHarnesses.has("cursor")) {
118
- utilitySkillChecks.push({
119
- file: ".cursor/rules/cclaw-workflow.mdc",
120
- needle: "cclaw-managed-cursor-workflow-rule",
121
- name: "rules:cursor:managed_marker"
122
- });
123
- utilitySkillChecks.push({
124
- file: ".cursor/rules/cclaw-workflow.mdc",
125
- needle: "/cc",
126
- name: "rules:cursor:next_command_guidance"
127
- });
128
- }
129
- for (const check of utilitySkillChecks) {
130
- rules.push({
131
- filePath: check.file,
132
- needle: check.needle,
133
- name: check.name
134
- });
135
- }
136
- const contentCache = new Map();
137
- const readCached = async (filePath) => {
138
- if (contentCache.has(filePath)) {
139
- return contentCache.get(filePath) ?? null;
140
- }
141
- if (!(await exists(filePath))) {
142
- contentCache.set(filePath, null);
143
- return null;
144
- }
145
- const content = await fs.readFile(filePath, "utf8");
146
- contentCache.set(filePath, content);
147
- return content;
148
- };
149
- for (const rule of rules) {
150
- const filePath = path.join(projectRoot, rule.filePath);
151
- const content = await readCached(filePath);
152
- if (content === null) {
153
- checks.push({
154
- name: rule.name,
155
- ok: false,
156
- details: `${filePath} not found`
157
- });
158
- continue;
159
- }
160
- checks.push({
161
- name: rule.name,
162
- ok: content.includes(rule.needle),
163
- details: `expect "${rule.needle}" in ${filePath}`
164
- });
165
- }
166
- return checks;
167
- }
@@ -1,9 +0,0 @@
1
- import type { FlowState } from "./flow-state.js";
2
- export interface RetroGateStatus {
3
- required: boolean;
4
- completed: boolean;
5
- compoundEntries: number;
6
- hasRetroArtifact: boolean;
7
- skipped: boolean;
8
- }
9
- export declare function evaluateRetroGate(projectRoot: string, state: FlowState): Promise<RetroGateStatus>;
@@ -1,47 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { RUNTIME_ROOT } from "./constants.js";
4
- import { exists } from "./fs-utils.js";
5
- function activeArtifactsPath(projectRoot) {
6
- return path.join(projectRoot, RUNTIME_ROOT, "artifacts");
7
- }
8
- function retroArtifactPath(projectRoot) {
9
- return path.join(activeArtifactsPath(projectRoot), "09-retro.md");
10
- }
11
- function parseIsoTimestamp(value) {
12
- if (!value || value.trim().length === 0)
13
- return null;
14
- const parsed = Date.parse(value);
15
- return Number.isFinite(parsed) ? parsed : null;
16
- }
17
- export async function evaluateRetroGate(projectRoot, state) {
18
- const required = state.completedStages.includes("ship");
19
- const artifactFile = retroArtifactPath(projectRoot);
20
- let hasRetroArtifact = false;
21
- if (await exists(artifactFile)) {
22
- try {
23
- const raw = await fs.readFile(artifactFile, "utf8");
24
- hasRetroArtifact = raw.trim().length > 0;
25
- }
26
- catch {
27
- hasRetroArtifact = false;
28
- }
29
- }
30
- const retroSkipReason = state.closeout.retroSkipReason?.trim() ?? "";
31
- const retroSkipped = state.closeout.retroSkipped === true && retroSkipReason.length > 0;
32
- const retroAccepted = hasRetroArtifact && parseIsoTimestamp(state.closeout.retroAcceptedAt) !== null;
33
- const compoundSkipped = state.closeout.compoundSkipped === true;
34
- const compoundReviewed = parseIsoTimestamp(state.closeout.compoundCompletedAt) !== null ||
35
- state.closeout.compoundPromoted > 0;
36
- const compoundEntries = compoundReviewed ? Math.max(0, Math.floor(state.closeout.compoundPromoted)) : 0;
37
- // Keep retro-gate deterministic from closeout state only:
38
- // retroComplete = (retroAccepted || retroSkipped) && (compoundReviewed || compoundSkipped)
39
- const completed = required ? (retroAccepted || retroSkipped) && (compoundReviewed || compoundSkipped) : true;
40
- return {
41
- required,
42
- completed,
43
- compoundEntries,
44
- hasRetroArtifact,
45
- skipped: retroSkipped
46
- };
47
- }
@@ -1,61 +0,0 @@
1
- import { type FlowState } from "./flow-state.js";
2
- import type { FlowStage } from "./types.js";
3
- export declare const ARCHIVE_DISPOSITIONS: readonly ["completed", "cancelled", "abandoned"];
4
- export type ArchiveDisposition = (typeof ARCHIVE_DISPOSITIONS)[number];
5
- export interface CclawRunMeta {
6
- id: string;
7
- title: string;
8
- createdAt: string;
9
- }
10
- export interface ArchiveRunResult {
11
- archiveId: string;
12
- archivePath: string;
13
- archivedAt: string;
14
- runName: string;
15
- resetState: FlowState;
16
- snapshottedStateFiles: string[];
17
- disposition: ArchiveDisposition;
18
- dispositionReason?: string;
19
- /** Knowledge curation hint: total active entries + soft threshold (50). */
20
- knowledge: {
21
- activeEntryCount: number;
22
- softThreshold: number;
23
- overThreshold: boolean;
24
- knowledgePath: string;
25
- };
26
- retro: {
27
- required: boolean;
28
- completed: boolean;
29
- skipped: boolean;
30
- skipReason?: string;
31
- compoundEntries: number;
32
- };
33
- }
34
- export interface ArchiveManifest {
35
- version: 2;
36
- archiveId: string;
37
- archivedAt: string;
38
- runName: string;
39
- sourceRunId: string;
40
- sourceCurrentStage: FlowStage;
41
- sourceCompletedStages: FlowStage[];
42
- snapshottedStateFiles: string[];
43
- disposition: ArchiveDisposition;
44
- dispositionReason?: string;
45
- retro: ArchiveRunResult["retro"];
46
- }
47
- export interface ArchiveRunOptions {
48
- skipRetro?: boolean;
49
- skipRetroReason?: string;
50
- disposition?: ArchiveDisposition;
51
- dispositionReason?: string;
52
- }
53
- export declare function listRuns(projectRoot: string): Promise<CclawRunMeta[]>;
54
- export declare function archiveRun(projectRoot: string, runName?: string, options?: ArchiveRunOptions): Promise<ArchiveRunResult>;
55
- /**
56
- * Counts entries in the canonical JSONL knowledge store. An "active" entry is one
57
- * non-empty line that parses as JSON with the required `type` field belonging to the
58
- * allowed set. Malformed lines are ignored (not counted) but do not throw so that a
59
- * hand-edited file cannot break sync/archive flows.
60
- */
61
- export declare function countActiveKnowledgeEntries(text: string): number;