prjct-cli 0.44.1 → 0.45.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.
Files changed (207) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/bin/prjct.ts +131 -10
  3. package/core/__tests__/agentic/memory-system.test.ts +39 -26
  4. package/core/__tests__/agentic/plan-mode.test.ts +64 -46
  5. package/core/__tests__/agentic/prompt-builder.test.ts +14 -14
  6. package/core/__tests__/services/project-index.test.ts +353 -0
  7. package/core/__tests__/types/fs.test.ts +3 -3
  8. package/core/__tests__/utils/date-helper.test.ts +10 -10
  9. package/core/__tests__/utils/output.test.ts +9 -6
  10. package/core/__tests__/utils/project-commands.test.ts +5 -6
  11. package/core/agentic/agent-router.ts +9 -10
  12. package/core/agentic/chain-of-thought.ts +16 -4
  13. package/core/agentic/command-executor.ts +66 -40
  14. package/core/agentic/context-builder.ts +8 -5
  15. package/core/agentic/ground-truth.ts +15 -9
  16. package/core/agentic/index.ts +145 -152
  17. package/core/agentic/loop-detector.ts +40 -11
  18. package/core/agentic/memory-system.ts +98 -35
  19. package/core/agentic/orchestrator-executor.ts +135 -71
  20. package/core/agentic/plan-mode.ts +46 -16
  21. package/core/agentic/prompt-builder.ts +108 -42
  22. package/core/agentic/services.ts +10 -9
  23. package/core/agentic/skill-loader.ts +9 -15
  24. package/core/agentic/smart-context.ts +129 -79
  25. package/core/agentic/template-executor.ts +13 -12
  26. package/core/agentic/template-loader.ts +7 -4
  27. package/core/agentic/tool-registry.ts +16 -13
  28. package/core/agents/index.ts +1 -1
  29. package/core/agents/performance.ts +10 -27
  30. package/core/ai-tools/formatters.ts +8 -6
  31. package/core/ai-tools/generator.ts +4 -4
  32. package/core/ai-tools/index.ts +1 -1
  33. package/core/ai-tools/registry.ts +21 -11
  34. package/core/bus/bus.ts +23 -16
  35. package/core/bus/index.ts +2 -2
  36. package/core/cli/linear.ts +3 -5
  37. package/core/cli/start.ts +28 -25
  38. package/core/commands/analysis.ts +287 -29
  39. package/core/commands/analytics.ts +52 -44
  40. package/core/commands/base.ts +15 -13
  41. package/core/commands/cleanup.ts +6 -13
  42. package/core/commands/command-data.ts +49 -8
  43. package/core/commands/commands.ts +60 -23
  44. package/core/commands/context.ts +4 -4
  45. package/core/commands/design.ts +3 -10
  46. package/core/commands/index.ts +5 -8
  47. package/core/commands/maintenance.ts +7 -4
  48. package/core/commands/planning.ts +179 -56
  49. package/core/commands/register.ts +14 -9
  50. package/core/commands/registry.ts +15 -14
  51. package/core/commands/setup.ts +26 -14
  52. package/core/commands/shipping.ts +11 -16
  53. package/core/commands/snapshots.ts +16 -32
  54. package/core/commands/uninstall.ts +541 -0
  55. package/core/commands/workflow.ts +24 -28
  56. package/core/constants/index.ts +10 -22
  57. package/core/context/generator.ts +82 -33
  58. package/core/context-tools/files-tool.ts +583 -0
  59. package/core/context-tools/imports-tool.ts +403 -0
  60. package/core/context-tools/index.ts +433 -0
  61. package/core/context-tools/recent-tool.ts +307 -0
  62. package/core/context-tools/signatures-tool.ts +501 -0
  63. package/core/context-tools/summary-tool.ts +307 -0
  64. package/core/context-tools/token-counter.ts +284 -0
  65. package/core/context-tools/types.ts +253 -0
  66. package/core/domain/agent-generator.ts +7 -5
  67. package/core/domain/agent-loader.ts +2 -2
  68. package/core/domain/analyzer.ts +19 -16
  69. package/core/domain/architecture-generator.ts +6 -3
  70. package/core/domain/context-estimator.ts +3 -4
  71. package/core/domain/snapshot-manager.ts +25 -22
  72. package/core/domain/task-stack.ts +24 -14
  73. package/core/errors.ts +1 -1
  74. package/core/events/events.ts +2 -4
  75. package/core/events/index.ts +1 -2
  76. package/core/index.ts +28 -12
  77. package/core/infrastructure/agent-detector.ts +3 -3
  78. package/core/infrastructure/ai-provider.ts +23 -20
  79. package/core/infrastructure/author-detector.ts +16 -10
  80. package/core/infrastructure/capability-installer.ts +2 -2
  81. package/core/infrastructure/claude-agent.ts +6 -6
  82. package/core/infrastructure/command-installer.ts +22 -17
  83. package/core/infrastructure/config-manager.ts +18 -14
  84. package/core/infrastructure/editors-config.ts +8 -4
  85. package/core/infrastructure/path-manager.ts +8 -6
  86. package/core/infrastructure/permission-manager.ts +20 -17
  87. package/core/infrastructure/setup.ts +42 -38
  88. package/core/infrastructure/update-checker.ts +5 -5
  89. package/core/integrations/issue-tracker/enricher.ts +8 -19
  90. package/core/integrations/issue-tracker/index.ts +2 -2
  91. package/core/integrations/issue-tracker/manager.ts +15 -15
  92. package/core/integrations/issue-tracker/types.ts +5 -22
  93. package/core/integrations/jira/client.ts +67 -59
  94. package/core/integrations/jira/index.ts +11 -14
  95. package/core/integrations/jira/mcp-adapter.ts +5 -10
  96. package/core/integrations/jira/service.ts +10 -10
  97. package/core/integrations/linear/client.ts +27 -18
  98. package/core/integrations/linear/index.ts +9 -12
  99. package/core/integrations/linear/service.ts +11 -11
  100. package/core/integrations/linear/sync.ts +8 -8
  101. package/core/outcomes/analyzer.ts +5 -18
  102. package/core/outcomes/index.ts +2 -2
  103. package/core/outcomes/recorder.ts +3 -3
  104. package/core/plugin/builtin/webhook.ts +19 -15
  105. package/core/plugin/hooks.ts +29 -21
  106. package/core/plugin/index.ts +7 -7
  107. package/core/plugin/loader.ts +19 -19
  108. package/core/plugin/registry.ts +12 -23
  109. package/core/schemas/agents.ts +1 -1
  110. package/core/schemas/analysis.ts +1 -1
  111. package/core/schemas/enriched-task.ts +62 -49
  112. package/core/schemas/ideas.ts +13 -13
  113. package/core/schemas/index.ts +17 -27
  114. package/core/schemas/issues.ts +40 -25
  115. package/core/schemas/metrics.ts +143 -0
  116. package/core/schemas/outcomes.ts +70 -62
  117. package/core/schemas/permissions.ts +15 -12
  118. package/core/schemas/prd.ts +27 -14
  119. package/core/schemas/project.ts +3 -3
  120. package/core/schemas/roadmap.ts +47 -34
  121. package/core/schemas/schemas.ts +3 -4
  122. package/core/schemas/shipped.ts +3 -3
  123. package/core/schemas/state.ts +43 -29
  124. package/core/server/index.ts +5 -6
  125. package/core/server/routes-extended.ts +68 -72
  126. package/core/server/routes.ts +3 -3
  127. package/core/server/server.ts +31 -26
  128. package/core/services/agent-generator.ts +237 -0
  129. package/core/services/agent-service.ts +2 -2
  130. package/core/services/breakdown-service.ts +2 -4
  131. package/core/services/context-generator.ts +299 -0
  132. package/core/services/context-selector.ts +420 -0
  133. package/core/services/doctor-service.ts +426 -0
  134. package/core/services/file-categorizer.ts +448 -0
  135. package/core/services/file-scorer.ts +270 -0
  136. package/core/services/git-analyzer.ts +267 -0
  137. package/core/services/index.ts +27 -10
  138. package/core/services/memory-service.ts +3 -4
  139. package/core/services/project-index.ts +911 -0
  140. package/core/services/project-service.ts +4 -4
  141. package/core/services/skill-installer.ts +14 -17
  142. package/core/services/skill-lock.ts +3 -3
  143. package/core/services/skill-service.ts +12 -6
  144. package/core/services/stack-detector.ts +245 -0
  145. package/core/services/sync-service.ts +170 -329
  146. package/core/services/watch-service.ts +294 -0
  147. package/core/session/compaction.ts +23 -31
  148. package/core/session/index.ts +11 -5
  149. package/core/session/log-migration.ts +3 -3
  150. package/core/session/metrics.ts +19 -14
  151. package/core/session/session-log-manager.ts +12 -17
  152. package/core/session/task-session-manager.ts +25 -25
  153. package/core/session/utils.ts +1 -1
  154. package/core/storage/ideas-storage.ts +41 -57
  155. package/core/storage/index-storage.ts +514 -0
  156. package/core/storage/index.ts +41 -13
  157. package/core/storage/metrics-storage.ts +320 -0
  158. package/core/storage/queue-storage.ts +35 -45
  159. package/core/storage/shipped-storage.ts +17 -20
  160. package/core/storage/state-storage.ts +50 -30
  161. package/core/storage/storage-manager.ts +6 -6
  162. package/core/storage/storage.ts +18 -15
  163. package/core/sync/auth-config.ts +3 -3
  164. package/core/sync/index.ts +13 -19
  165. package/core/sync/oauth-handler.ts +3 -3
  166. package/core/sync/sync-client.ts +4 -9
  167. package/core/sync/sync-manager.ts +12 -14
  168. package/core/types/commands.ts +42 -7
  169. package/core/types/index.ts +284 -302
  170. package/core/types/integrations.ts +3 -3
  171. package/core/types/storage.ts +49 -0
  172. package/core/types/utils.ts +3 -3
  173. package/core/utils/agent-stream.ts +3 -1
  174. package/core/utils/animations.ts +14 -11
  175. package/core/utils/branding.ts +7 -7
  176. package/core/utils/cache.ts +1 -3
  177. package/core/utils/collection-filters.ts +3 -15
  178. package/core/utils/date-helper.ts +2 -7
  179. package/core/utils/file-helper.ts +13 -8
  180. package/core/utils/jsonl-helper.ts +13 -10
  181. package/core/utils/keychain.ts +4 -8
  182. package/core/utils/logger.ts +1 -1
  183. package/core/utils/next-steps.ts +3 -3
  184. package/core/utils/output.ts +58 -11
  185. package/core/utils/project-commands.ts +6 -6
  186. package/core/utils/project-credentials.ts +5 -12
  187. package/core/utils/runtime.ts +2 -2
  188. package/core/utils/session-helper.ts +3 -4
  189. package/core/utils/version.ts +3 -3
  190. package/core/wizard/index.ts +13 -0
  191. package/core/wizard/onboarding.ts +633 -0
  192. package/core/workflow/state-machine.ts +7 -7
  193. package/dist/bin/prjct.mjs +18907 -13189
  194. package/dist/core/infrastructure/command-installer.js +96 -111
  195. package/dist/core/infrastructure/editors-config.js +6 -6
  196. package/dist/core/infrastructure/setup.js +256 -257
  197. package/dist/core/utils/version.js +9 -9
  198. package/package.json +11 -12
  199. package/scripts/build.js +3 -3
  200. package/scripts/postinstall.js +2 -2
  201. package/templates/mcp-config.json +6 -1
  202. package/templates/permissions/permissive.jsonc +1 -1
  203. package/templates/permissions/strict.jsonc +5 -9
  204. package/templates/global/docs/agents.md +0 -88
  205. package/templates/global/docs/architecture.md +0 -103
  206. package/templates/global/docs/commands.md +0 -96
  207. package/templates/global/docs/validation.md +0 -95
@@ -6,30 +6,29 @@
6
6
  * @version 3.4
7
7
  */
8
8
 
9
- import fs from 'fs'
10
- import path from 'path'
11
- import os from 'os'
12
- import templateLoader from './template-loader'
13
- import contextBuilder from './context-builder'
14
- import promptBuilder from './prompt-builder'
15
- import toolRegistry from './tool-registry'
16
- import loopDetector from './loop-detector'
17
- import chainOfThought from './chain-of-thought'
18
- import memorySystem from './memory-system'
19
- import groundTruth from './ground-truth'
20
- import planMode from './plan-mode'
21
- import templateExecutor from './template-executor'
22
- import orchestratorExecutor from './orchestrator-executor'
23
- import { agentStream } from '../utils/agent-stream'
24
-
9
+ import fs from 'node:fs'
10
+ import os from 'node:os'
11
+ import path from 'node:path'
25
12
  import type {
26
- OrchestratorContext,
13
+ ApprovalContext,
27
14
  ExecutionResult,
28
- SimpleExecutionResult,
29
15
  ExecutionToolsFn,
30
- ApprovalContext,
16
+ OrchestratorContext,
31
17
  PromptContext,
18
+ SimpleExecutionResult,
32
19
  } from '../types'
20
+ import { agentStream } from '../utils/agent-stream'
21
+ import chainOfThought from './chain-of-thought'
22
+ import contextBuilder from './context-builder'
23
+ import groundTruth from './ground-truth'
24
+ import loopDetector from './loop-detector'
25
+ import memorySystem from './memory-system'
26
+ import orchestratorExecutor from './orchestrator-executor'
27
+ import planMode from './plan-mode'
28
+ import promptBuilder from './prompt-builder'
29
+ import templateExecutor from './template-executor'
30
+ import templateLoader from './template-loader'
31
+ import toolRegistry from './tool-registry'
33
32
 
34
33
  // =============================================================================
35
34
  // Status Signal
@@ -135,11 +134,7 @@ export class CommandExecutor {
135
134
  let groundTruthResult = null
136
135
  if (groundTruth.requiresVerification(commandName)) {
137
136
  const preState = await contextBuilder.loadStateForCommand(metadataContext, commandName)
138
- groundTruthResult = await groundTruth.verify(
139
- commandName,
140
- metadataContext,
141
- preState
142
- )
137
+ groundTruthResult = await groundTruth.verify(commandName, metadataContext, preState)
143
138
 
144
139
  // Log warnings but don't block (user can override)
145
140
  if (!groundTruthResult.verified && groundTruthResult.warnings.length > 0) {
@@ -150,12 +145,11 @@ export class CommandExecutor {
150
145
  // 2.8. CHAIN OF THOUGHT: Reasoning for critical commands
151
146
  let reasoning = null
152
147
  if (chainOfThought.requiresReasoning(commandName)) {
153
- const reasoningState = await contextBuilder.loadStateForCommand(metadataContext, commandName)
154
- reasoning = await chainOfThought.reason(
155
- commandName,
148
+ const reasoningState = await contextBuilder.loadStateForCommand(
156
149
  metadataContext,
157
- reasoningState
150
+ commandName
158
151
  )
152
+ reasoning = await chainOfThought.reason(commandName, metadataContext, reasoningState)
159
153
 
160
154
  // If reasoning shows critical issues, warn but continue
161
155
  if (reasoning.reasoning && !reasoning.reasoning.allPassed) {
@@ -225,9 +219,18 @@ export class CommandExecutor {
225
219
  let relevantMemories = null
226
220
  if (metadataContext.projectId) {
227
221
  learnedPatterns = {
228
- commit_footer: await memorySystem.getSmartDecision(metadataContext.projectId, 'commit_footer'),
229
- branch_naming: await memorySystem.getSmartDecision(metadataContext.projectId, 'branch_naming'),
230
- test_before_ship: await memorySystem.getSmartDecision(metadataContext.projectId, 'test_before_ship'),
222
+ commit_footer: await memorySystem.getSmartDecision(
223
+ metadataContext.projectId,
224
+ 'commit_footer'
225
+ ),
226
+ branch_naming: await memorySystem.getSmartDecision(
227
+ metadataContext.projectId,
228
+ 'branch_naming'
229
+ ),
230
+ test_before_ship: await memorySystem.getSmartDecision(
231
+ metadataContext.projectId,
232
+ 'test_before_ship'
233
+ ),
231
234
  preferred_agent: await memorySystem.getSmartDecision(
232
235
  metadataContext.projectId,
233
236
  `preferred_agent_${commandName}`
@@ -247,7 +250,10 @@ export class CommandExecutor {
247
250
  isPlanning: requiresPlanning || isInPlanningMode,
248
251
  requiresApproval: isDestructive && !params.approved,
249
252
  active: activePlan,
250
- allowedTools: planMode.getAllowedTools(isInPlanningMode, template.frontmatter['allowed-tools'] || []),
253
+ allowedTools: planMode.getAllowedTools(
254
+ isInPlanningMode,
255
+ template.frontmatter['allowed-tools'] || []
256
+ ),
251
257
  }
252
258
  // Agent is null - Claude assigns via Task tool using agent-routing.md
253
259
  // Pass orchestratorContext for domain/agent/subtask injection
@@ -297,7 +303,10 @@ export class CommandExecutor {
297
303
  orchestratorContext,
298
304
  memory: {
299
305
  create: (memory: unknown) =>
300
- memorySystem.createMemory(metadataContext.projectId!, memory as Parameters<typeof memorySystem.createMemory>[1]),
306
+ memorySystem.createMemory(
307
+ metadataContext.projectId!,
308
+ memory as Parameters<typeof memorySystem.createMemory>[1]
309
+ ),
301
310
  autoRemember: (type: string, value: string, ctx?: string) =>
302
311
  memorySystem.autoRemember(metadataContext.projectId!, type, value, ctx),
303
312
  search: (query: string) => memorySystem.searchMemories(metadataContext.projectId!, query),
@@ -310,12 +319,24 @@ export class CommandExecutor {
310
319
  isDestructive,
311
320
  requiresApproval: isDestructive && !params.approved,
312
321
  recordInfo: (info: unknown) =>
313
- planMode.recordGatheredInfo(metadataContext.projectId!, info as Parameters<typeof planMode.recordGatheredInfo>[1]),
314
- setAnalysis: (analysis: unknown) => planMode.setAnalysis(metadataContext.projectId!, analysis as Parameters<typeof planMode.setAnalysis>[1]),
322
+ planMode.recordGatheredInfo(
323
+ metadataContext.projectId!,
324
+ info as Parameters<typeof planMode.recordGatheredInfo>[1]
325
+ ),
326
+ setAnalysis: (analysis: unknown) =>
327
+ planMode.setAnalysis(
328
+ metadataContext.projectId!,
329
+ analysis as Parameters<typeof planMode.setAnalysis>[1]
330
+ ),
315
331
  propose: (plan: unknown) =>
316
- planMode.proposePlan(metadataContext.projectId!, plan as Parameters<typeof planMode.proposePlan>[1]),
317
- approve: (feedback?: string | null) => planMode.approvePlan(metadataContext.projectId!, feedback),
318
- reject: (reason?: string | null) => planMode.rejectPlan(metadataContext.projectId!, reason),
332
+ planMode.proposePlan(
333
+ metadataContext.projectId!,
334
+ plan as Parameters<typeof planMode.proposePlan>[1]
335
+ ),
336
+ approve: (feedback?: string | null) =>
337
+ planMode.approvePlan(metadataContext.projectId!, feedback),
338
+ reject: (reason?: string | null) =>
339
+ planMode.rejectPlan(metadataContext.projectId!, reason),
319
340
  getApprovalPrompt: () =>
320
341
  planMode.generateApprovalPrompt(commandName, {
321
342
  // Reason: `context` here is the command execution context, not the plan-mode ApprovalContext.
@@ -331,7 +352,11 @@ export class CommandExecutor {
331
352
  } satisfies ApprovalContext),
332
353
  startExecution: () => planMode.startExecution(metadataContext.projectId!),
333
354
  getNextStep: () => planMode.getNextStep(metadataContext.projectId!),
334
- completeStep: (result?: unknown) => planMode.completeStep(metadataContext.projectId!, result as Parameters<typeof planMode.completeStep>[1]),
355
+ completeStep: (result?: unknown) =>
356
+ planMode.completeStep(
357
+ metadataContext.projectId!,
358
+ result as Parameters<typeof planMode.completeStep>[1]
359
+ ),
335
360
  failStep: (error: string) => planMode.failStep(metadataContext.projectId!, error),
336
361
  abort: (reason?: string) => planMode.abortPlan(metadataContext.projectId!, reason),
337
362
  getStatus: () => planMode.formatStatus(metadataContext.projectId!),
@@ -408,7 +433,8 @@ export class CommandExecutor {
408
433
  // Create tools proxy that checks permissions
409
434
  const tools = {
410
435
  read: async (filePath: string) => this.executeTool('Read', [filePath], allowedTools),
411
- write: async (filePath: string, content: string) => this.executeTool('Write', [filePath, content], allowedTools),
436
+ write: async (filePath: string, content: string) =>
437
+ this.executeTool('Write', [filePath, content], allowedTools),
412
438
  bash: async (command: string) => this.executeTool('Bash', [command], allowedTools),
413
439
  }
414
440
 
@@ -6,14 +6,14 @@
6
6
  * @version 0.1
7
7
  */
8
8
 
9
- import fs from 'fs/promises'
10
- import pathManager from '../infrastructure/path-manager'
9
+ import fs from 'node:fs/promises'
11
10
  import configManager from '../infrastructure/config-manager'
11
+ import pathManager from '../infrastructure/path-manager'
12
+ import type { ContextPaths, ContextState, ProjectContext } from '../types'
12
13
  import { isNotFoundError } from '../types/fs'
13
- import type { ContextPaths, ProjectContext, ContextState } from '../types'
14
14
 
15
15
  // Re-export types for convenience
16
- export type { ContextPaths, ProjectContext, ContextState } from '../types'
16
+ export type { ContextPaths, ContextState, ProjectContext } from '../types'
17
17
 
18
18
  // Local type aliases for backward compatibility
19
19
  type Paths = ContextPaths
@@ -140,7 +140,10 @@ class ContextBuilder {
140
140
  if (uncachedEntries.length > 0) {
141
141
  const readPromises = uncachedEntries.map(async ([key, filePath]) => {
142
142
  try {
143
- const [content, stat] = await Promise.all([fs.readFile(filePath, 'utf-8'), fs.stat(filePath)])
143
+ const [content, stat] = await Promise.all([
144
+ fs.readFile(filePath, 'utf-8'),
145
+ fs.stat(filePath),
146
+ ])
144
147
  return { key, filePath, content, mtime: stat.mtimeMs }
145
148
  } catch (error) {
146
149
  if (isNotFoundError(error)) {
@@ -11,10 +11,10 @@
11
11
  * Source: Devin, Cursor, Augment Code patterns
12
12
  */
13
13
 
14
- import fs from 'fs/promises'
15
- import path from 'path'
16
- import os from 'os'
17
- import { execSync } from 'child_process'
14
+ import { execSync } from 'node:child_process'
15
+ import fs from 'node:fs/promises'
16
+ import os from 'node:os'
17
+ import path from 'node:path'
18
18
 
19
19
  import type { GroundTruthContext, VerificationResult, Verifier } from '../types'
20
20
  import { isNotFoundError } from '../types/fs'
@@ -99,7 +99,7 @@ export async function verifyDone(context: GroundTruthContext): Promise<Verificat
99
99
  actual.startedAt = startedMatch[1]
100
100
  // Calculate duration
101
101
  const startTime = new Date(startedMatch[1])
102
- if (!isNaN(startTime.getTime())) {
102
+ if (!Number.isNaN(startTime.getTime())) {
103
103
  actual.durationMs = Date.now() - startTime.getTime()
104
104
  actual.durationFormatted = formatDuration(actual.durationMs as number)
105
105
  }
@@ -174,7 +174,7 @@ export async function verifyShip(context: GroundTruthContext): Promise<Verificat
174
174
  warnings.push(`${actual.uncommittedFiles} uncommitted file(s)`)
175
175
  recommendations.push('Commit changes before shipping')
176
176
  }
177
- } catch (error) {
177
+ } catch (_error) {
178
178
  // Git errors (not a repo, git not installed) are not blockers
179
179
  actual.gitAvailable = false
180
180
  }
@@ -341,7 +341,9 @@ export async function verifyNow(context: GroundTruthContext): Promise<Verificati
341
341
  actual.nowContent = nowContent.trim()
342
342
 
343
343
  const hasRealTask =
344
- nowContent.trim().length > 0 && !nowContent.includes('No current task') && !nowContent.match(/^#\s*NOW\s*$/m)
344
+ nowContent.trim().length > 0 &&
345
+ !nowContent.includes('No current task') &&
346
+ !nowContent.match(/^#\s*NOW\s*$/m)
345
347
 
346
348
  actual.hasActiveTask = hasRealTask
347
349
 
@@ -426,7 +428,7 @@ export async function verifyInit(context: GroundTruthContext): Promise<Verificat
426
428
  await fs.mkdir(globalPath, { recursive: true })
427
429
  actual.globalPathWritable = true
428
430
  actual.globalPathCreated = true
429
- } catch (mkdirError) {
431
+ } catch (_mkdirError) {
430
432
  actual.globalPathWritable = false
431
433
  warnings.push('Cannot write to ~/.prjct-cli')
432
434
  recommendations.push('Check directory permissions')
@@ -657,7 +659,11 @@ export async function verify(
657
659
  * Prepare command by verifying ground truth
658
660
  * Returns enhanced context with verification results
659
661
  */
660
- export async function prepareCommand(commandName: string, context: GroundTruthContext, state: unknown) {
662
+ export async function prepareCommand(
663
+ commandName: string,
664
+ context: GroundTruthContext,
665
+ state: unknown
666
+ ) {
661
667
  const verification = await verify(commandName, context, state)
662
668
 
663
669
  return {
@@ -10,178 +10,171 @@
10
10
  * - Tools: Tool registry, template loader
11
11
  */
12
12
 
13
- // ============ Memory ============
14
- // Pattern learning, semantic memories, session history
15
- export {
16
- default as memorySystem,
17
- MemorySystem,
18
- CachedStore,
19
- PatternStore,
20
- SemanticMemories,
21
- HistoryStore,
22
- SessionStore,
23
- MEMORY_TAGS,
24
- } from './memory-system'
25
-
26
- // ============ Planning ============
27
- // Plan mode for complex tasks
28
- export {
29
- default as planMode,
30
- PlanMode,
31
- generateApprovalPrompt,
32
- PLAN_STATUS,
33
- PLAN_REQUIRED_COMMANDS,
34
- DESTRUCTIVE_COMMANDS,
35
- PLANNING_TOOLS,
36
- } from './plan-mode'
37
-
13
+ // ============ Types ============
14
+ // All types re-exported from ../types (canonical source)
15
+ export type {
16
+ // Agent router types
17
+ Agent,
18
+ AgentInfo,
19
+ ApprovalContext,
20
+ ApprovalOperation,
21
+ ApprovalOption,
22
+ ApprovalPrompt,
23
+ AssignmentContext,
24
+ AttemptInfo,
25
+ AttemptRecord,
26
+ AttemptResult,
27
+ // Chain of Thought types
28
+ ChainOfThoughtContext,
29
+ ChainOfThoughtResult,
30
+ ChainOfThoughtState,
31
+ ChangedFile,
32
+ // Smart context types
33
+ ContextDomain,
34
+ // Context builder types
35
+ ContextPaths,
36
+ ContextState,
37
+ Decision,
38
+ DomainAnalysis,
39
+ // Loop Detector types
40
+ ErrorEntry,
41
+ ErrorPattern,
42
+ EscalationInfo,
43
+ // Execution types
44
+ ExecutionResult,
45
+ ExecutionToolsFn,
46
+ FeatureInfo,
47
+ FilteredContext,
48
+ FilterMetrics,
49
+ // Prompt builder types
50
+ Frontmatter,
51
+ FullContext,
52
+ GatheredAnalysisData,
53
+ GatheredFileData,
54
+ GatheredInfo,
55
+ GatheredInfoType,
56
+ // Ground Truth types
57
+ GroundTruthContext,
58
+ HallucinationPattern,
59
+ HallucinationResult,
60
+ HistoryEntry,
61
+ HistoryEventType,
62
+ LearnedPatterns,
63
+ LoadedAgent,
64
+ LoadedSkill,
65
+ // Memory types
66
+ Memory,
67
+ MemoryContext,
68
+ MemoryContextParams,
69
+ MemoryDatabase,
70
+ MemoryTag,
71
+ // Orchestrator types
72
+ OrchestratorContext,
73
+ OrchestratorSubtask,
74
+ OutputAnalysis,
75
+ PatternInfo,
76
+ Patterns,
77
+ Plan,
78
+ PlanAnalysis,
79
+ PlanInfo,
80
+ // Plan Mode types
81
+ PlanParams,
82
+ PlanStatus,
83
+ PlanStep,
84
+ PlanStepDefinition,
85
+ PlanStepResult,
86
+ Preference,
87
+ ProjectContext,
88
+ ProposedPlan,
89
+ ReasoningResult,
90
+ ReasoningStep,
91
+ SimpleExecutionResult,
92
+ StackInfo,
93
+ Template,
94
+ ThinkBlock,
95
+ // Tool registry types
96
+ ToolFunction,
97
+ ToolRegistryInterface,
98
+ VerificationResult,
99
+ Verifier,
100
+ Workflow,
101
+ } from '../types'
102
+ // ============ Routing ============
103
+ // Agent routing and ground truth verification
104
+ export { default as AgentRouter } from './agent-router'
105
+ // ============ Utilities ============
106
+ // Chain of thought, services
107
+ export { default as chainOfThought } from './chain-of-thought'
38
108
  // ============ Execution ============
39
109
  // Command execution, loop detection
40
110
  export {
41
- default as commandExecutor,
42
111
  CommandExecutor,
43
- signalStart,
112
+ default as commandExecutor,
44
113
  signalEnd,
114
+ signalStart,
45
115
  } from './command-executor'
46
116
 
47
- export {
48
- default as loopDetector,
49
- LoopDetector,
50
- HALLUCINATION_PATTERNS,
51
- detectHallucination,
52
- getHallucinationSuggestion,
53
- isSimilarError,
54
- analyzeErrorPattern,
55
- generateEscalationMessage,
56
- generateSuggestion,
57
- } from './loop-detector'
58
-
59
117
  // ============ Context ============
60
118
  // Context building and prompt generation
61
119
  export { default as contextBuilder } from './context-builder'
62
- export { default as smartContext } from './smart-context'
63
- export { default as promptBuilder } from './prompt-builder'
64
-
65
- // ============ Routing ============
66
- // Agent routing and ground truth verification
67
- export { default as AgentRouter } from './agent-router'
68
120
  export {
69
121
  default as groundTruth,
70
- verify,
122
+ escapeRegex,
123
+ formatDuration,
124
+ formatWarnings,
71
125
  prepareCommand,
72
126
  requiresVerification,
73
127
  verifiers,
128
+ verify,
129
+ verifyAnalyze,
74
130
  verifyDone,
75
- verifyShip,
76
131
  verifyFeature,
77
- verifyNow,
78
132
  verifyInit,
79
- verifySync,
80
- verifyAnalyze,
133
+ verifyNow,
134
+ verifyShip,
81
135
  verifySpec,
82
- formatDuration,
83
- escapeRegex,
84
- formatWarnings,
136
+ verifySync,
85
137
  } from './ground-truth'
86
-
138
+ export {
139
+ analyzeErrorPattern,
140
+ default as loopDetector,
141
+ detectHallucination,
142
+ generateEscalationMessage,
143
+ generateSuggestion,
144
+ getHallucinationSuggestion,
145
+ HALLUCINATION_PATTERNS,
146
+ isSimilarError,
147
+ LoopDetector,
148
+ } from './loop-detector'
149
+ // ============ Memory ============
150
+ // Pattern learning, semantic memories, session history
151
+ export {
152
+ CachedStore,
153
+ default as memorySystem,
154
+ HistoryStore,
155
+ MEMORY_TAGS,
156
+ MemorySystem,
157
+ PatternStore,
158
+ SemanticMemories,
159
+ SessionStore,
160
+ } from './memory-system'
161
+ export { default as orchestratorExecutor, OrchestratorExecutor } from './orchestrator-executor'
162
+ // ============ Planning ============
163
+ // Plan mode for complex tasks
164
+ export {
165
+ DESTRUCTIVE_COMMANDS,
166
+ default as planMode,
167
+ generateApprovalPrompt,
168
+ PLAN_REQUIRED_COMMANDS,
169
+ PLAN_STATUS,
170
+ PLANNING_TOOLS,
171
+ PlanMode,
172
+ } from './plan-mode'
173
+ export { default as promptBuilder } from './prompt-builder'
174
+ export { default as services } from './services'
175
+ export { default as smartContext } from './smart-context'
176
+ export { default as templateExecutor, TemplateExecutor } from './template-executor'
177
+ export { default as templateLoader } from './template-loader'
87
178
  // ============ Tools ============
88
179
  // Tool and template management
89
180
  export { default as toolRegistry } from './tool-registry'
90
- export { default as templateLoader } from './template-loader'
91
- export { default as templateExecutor, TemplateExecutor } from './template-executor'
92
- export { default as orchestratorExecutor, OrchestratorExecutor } from './orchestrator-executor'
93
-
94
- // ============ Utilities ============
95
- // Chain of thought, services
96
- export { default as chainOfThought } from './chain-of-thought'
97
- export { default as services } from './services'
98
-
99
- // ============ Types ============
100
- // All types re-exported from ../types (canonical source)
101
- export type {
102
- // Memory types
103
- Memory,
104
- MemoryTag,
105
- MemoryDatabase,
106
- HistoryEntry,
107
- HistoryEventType,
108
- Decision,
109
- Workflow,
110
- Preference,
111
- Patterns,
112
- MemoryContext,
113
- MemoryContextParams,
114
- // Plan Mode types
115
- PlanParams,
116
- GatheredInfo,
117
- GatheredInfoType,
118
- GatheredFileData,
119
- GatheredAnalysisData,
120
- ProposedPlan,
121
- PlanStepDefinition,
122
- PlanStep,
123
- PlanStepResult,
124
- PlanStatus,
125
- Plan,
126
- PlanAnalysis,
127
- ApprovalPrompt,
128
- ApprovalOption,
129
- ApprovalContext,
130
- ChangedFile,
131
- ApprovalOperation,
132
- // Execution types
133
- ExecutionResult,
134
- SimpleExecutionResult,
135
- ExecutionToolsFn,
136
- // Loop Detector types
137
- ErrorEntry,
138
- AttemptRecord,
139
- ErrorPattern,
140
- EscalationInfo,
141
- AttemptResult,
142
- AttemptInfo,
143
- HallucinationPattern,
144
- HallucinationResult,
145
- OutputAnalysis,
146
- // Ground Truth types
147
- GroundTruthContext,
148
- VerificationResult,
149
- Verifier,
150
- // Tool registry types
151
- ToolFunction,
152
- ToolRegistryInterface,
153
- // Agent router types
154
- Agent,
155
- AssignmentContext,
156
- // Context builder types
157
- ContextPaths,
158
- ProjectContext,
159
- ContextState,
160
- // Smart context types
161
- ContextDomain,
162
- FullContext,
163
- FilteredContext,
164
- AgentInfo,
165
- FeatureInfo,
166
- PatternInfo,
167
- StackInfo,
168
- FilterMetrics,
169
- DomainAnalysis,
170
- // Prompt builder types
171
- Frontmatter,
172
- Template,
173
- LearnedPatterns,
174
- ThinkBlock,
175
- PlanInfo,
176
- // Chain of Thought types
177
- ChainOfThoughtContext,
178
- ChainOfThoughtState,
179
- ReasoningStep,
180
- ReasoningResult,
181
- ChainOfThoughtResult,
182
- // Orchestrator types
183
- OrchestratorContext,
184
- LoadedAgent,
185
- LoadedSkill,
186
- OrchestratorSubtask,
187
- } from '../types'
@@ -17,12 +17,12 @@
17
17
  */
18
18
 
19
19
  import type {
20
- ErrorEntry,
20
+ AttemptInfo,
21
21
  AttemptRecord,
22
+ AttemptResult,
23
+ ErrorEntry,
22
24
  ErrorPattern,
23
25
  EscalationInfo,
24
- AttemptResult,
25
- AttemptInfo,
26
26
  HallucinationPattern,
27
27
  HallucinationResult,
28
28
  OutputAnalysis,
@@ -38,9 +38,21 @@ import type {
38
38
  */
39
39
  export const HALLUCINATION_PATTERNS: HallucinationPattern[] = [
40
40
  // Contradictory file operations
41
- { pattern: /file.*not found.*created/i, type: 'contradiction', description: 'Claims file created but also not found' },
42
- { pattern: /created.*but.*error/i, type: 'contradiction', description: 'Claims success but also error' },
43
- { pattern: /successfully.*failed/i, type: 'contradiction', description: 'Contradictory success/failure' },
41
+ {
42
+ pattern: /file.*not found.*created/i,
43
+ type: 'contradiction',
44
+ description: 'Claims file created but also not found',
45
+ },
46
+ {
47
+ pattern: /created.*but.*error/i,
48
+ type: 'contradiction',
49
+ description: 'Claims success but also error',
50
+ },
51
+ {
52
+ pattern: /successfully.*failed/i,
53
+ type: 'contradiction',
54
+ description: 'Contradictory success/failure',
55
+ },
44
56
 
45
57
  // Impossible task states
46
58
  {
@@ -48,8 +60,16 @@ export const HALLUCINATION_PATTERNS: HallucinationPattern[] = [
48
60
  type: 'state',
49
61
  description: 'Completing already-completed task',
50
62
  },
51
- { pattern: /no task.*marking complete/i, type: 'state', description: 'Completing non-existent task' },
52
- { pattern: /no.*active.*done with/i, type: 'state', description: 'Finishing task that doesnt exist' },
63
+ {
64
+ pattern: /no task.*marking complete/i,
65
+ type: 'state',
66
+ description: 'Completing non-existent task',
67
+ },
68
+ {
69
+ pattern: /no.*active.*done with/i,
70
+ type: 'state',
71
+ description: 'Finishing task that doesnt exist',
72
+ },
53
73
 
54
74
  // Invented data
55
75
  {
@@ -57,7 +77,11 @@ export const HALLUCINATION_PATTERNS: HallucinationPattern[] = [
57
77
  type: 'invented',
58
78
  description: 'Version update without package.json',
59
79
  },
60
- { pattern: /committed.*nothing to commit/i, type: 'invented', description: 'Commit without changes' },
80
+ {
81
+ pattern: /committed.*nothing to commit/i,
82
+ type: 'invented',
83
+ description: 'Commit without changes',
84
+ },
61
85
  { pattern: /pushed.*no remote/i, type: 'invented', description: 'Push without remote' },
62
86
  ]
63
87
 
@@ -70,7 +94,8 @@ export const HALLUCINATION_PATTERNS: HallucinationPattern[] = [
70
94
  */
71
95
  export function getHallucinationSuggestion(type: string): string {
72
96
  const suggestions: Record<string, string> = {
73
- contradiction: 'Verify file/resource state before reporting. Use Read tool to check actual state.',
97
+ contradiction:
98
+ 'Verify file/resource state before reporting. Use Read tool to check actual state.',
74
99
  state: 'Check current task state from now.md before assuming completion.',
75
100
  invented: 'Verify prerequisites exist (package.json, git remote) before claiming actions.',
76
101
  }
@@ -163,7 +188,11 @@ export function analyzeErrorPattern(errors: ErrorEntry[]): ErrorPattern {
163
188
  /**
164
189
  * Generate user-friendly escalation message
165
190
  */
166
- export function generateEscalationMessage(command: string, errorPattern: ErrorPattern, maxAttempts: number): string {
191
+ export function generateEscalationMessage(
192
+ command: string,
193
+ errorPattern: ErrorPattern,
194
+ maxAttempts: number
195
+ ): string {
167
196
  const messages: Record<string, string> = {
168
197
  permission: `I've tried ${command} ${maxAttempts} times but keep hitting permission issues.`,
169
198
  not_found: `After ${maxAttempts} attempts, I still can't find the required file or resource.`,