prjct-cli 0.45.0 → 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.
- package/CHANGELOG.md +75 -0
- package/bin/prjct.ts +117 -10
- package/core/__tests__/agentic/memory-system.test.ts +39 -26
- package/core/__tests__/agentic/plan-mode.test.ts +64 -46
- package/core/__tests__/agentic/prompt-builder.test.ts +14 -14
- package/core/__tests__/services/project-index.test.ts +353 -0
- package/core/__tests__/types/fs.test.ts +3 -3
- package/core/__tests__/utils/date-helper.test.ts +10 -10
- package/core/__tests__/utils/output.test.ts +9 -6
- package/core/__tests__/utils/project-commands.test.ts +5 -6
- package/core/agentic/agent-router.ts +9 -10
- package/core/agentic/chain-of-thought.ts +16 -4
- package/core/agentic/command-executor.ts +66 -40
- package/core/agentic/context-builder.ts +8 -5
- package/core/agentic/ground-truth.ts +15 -9
- package/core/agentic/index.ts +145 -152
- package/core/agentic/loop-detector.ts +40 -11
- package/core/agentic/memory-system.ts +98 -35
- package/core/agentic/orchestrator-executor.ts +135 -71
- package/core/agentic/plan-mode.ts +46 -16
- package/core/agentic/prompt-builder.ts +108 -42
- package/core/agentic/services.ts +10 -9
- package/core/agentic/skill-loader.ts +9 -15
- package/core/agentic/smart-context.ts +129 -79
- package/core/agentic/template-executor.ts +13 -12
- package/core/agentic/template-loader.ts +7 -4
- package/core/agentic/tool-registry.ts +16 -13
- package/core/agents/index.ts +1 -1
- package/core/agents/performance.ts +10 -27
- package/core/ai-tools/formatters.ts +8 -6
- package/core/ai-tools/generator.ts +4 -4
- package/core/ai-tools/index.ts +1 -1
- package/core/ai-tools/registry.ts +21 -11
- package/core/bus/bus.ts +23 -16
- package/core/bus/index.ts +2 -2
- package/core/cli/linear.ts +3 -5
- package/core/cli/start.ts +28 -25
- package/core/commands/analysis.ts +58 -39
- package/core/commands/analytics.ts +52 -44
- package/core/commands/base.ts +15 -13
- package/core/commands/cleanup.ts +6 -13
- package/core/commands/command-data.ts +28 -4
- package/core/commands/commands.ts +57 -24
- package/core/commands/context.ts +4 -4
- package/core/commands/design.ts +3 -10
- package/core/commands/index.ts +5 -8
- package/core/commands/maintenance.ts +7 -4
- package/core/commands/planning.ts +179 -56
- package/core/commands/register.ts +13 -9
- package/core/commands/registry.ts +15 -14
- package/core/commands/setup.ts +26 -14
- package/core/commands/shipping.ts +11 -16
- package/core/commands/snapshots.ts +16 -32
- package/core/commands/uninstall.ts +541 -0
- package/core/commands/workflow.ts +24 -28
- package/core/constants/index.ts +10 -22
- package/core/context/generator.ts +82 -33
- package/core/context-tools/files-tool.ts +18 -19
- package/core/context-tools/imports-tool.ts +13 -33
- package/core/context-tools/index.ts +29 -54
- package/core/context-tools/recent-tool.ts +16 -22
- package/core/context-tools/signatures-tool.ts +17 -26
- package/core/context-tools/summary-tool.ts +20 -22
- package/core/context-tools/token-counter.ts +25 -20
- package/core/context-tools/types.ts +5 -5
- package/core/domain/agent-generator.ts +7 -5
- package/core/domain/agent-loader.ts +2 -2
- package/core/domain/analyzer.ts +19 -16
- package/core/domain/architecture-generator.ts +6 -3
- package/core/domain/context-estimator.ts +3 -4
- package/core/domain/snapshot-manager.ts +25 -22
- package/core/domain/task-stack.ts +24 -14
- package/core/errors.ts +1 -1
- package/core/events/events.ts +2 -4
- package/core/events/index.ts +1 -2
- package/core/index.ts +28 -16
- package/core/infrastructure/agent-detector.ts +3 -3
- package/core/infrastructure/ai-provider.ts +23 -20
- package/core/infrastructure/author-detector.ts +16 -10
- package/core/infrastructure/capability-installer.ts +2 -2
- package/core/infrastructure/claude-agent.ts +6 -6
- package/core/infrastructure/command-installer.ts +22 -17
- package/core/infrastructure/config-manager.ts +18 -14
- package/core/infrastructure/editors-config.ts +8 -4
- package/core/infrastructure/path-manager.ts +8 -6
- package/core/infrastructure/permission-manager.ts +20 -17
- package/core/infrastructure/setup.ts +42 -38
- package/core/infrastructure/update-checker.ts +5 -5
- package/core/integrations/issue-tracker/enricher.ts +8 -19
- package/core/integrations/issue-tracker/index.ts +2 -2
- package/core/integrations/issue-tracker/manager.ts +15 -15
- package/core/integrations/issue-tracker/types.ts +5 -22
- package/core/integrations/jira/client.ts +67 -59
- package/core/integrations/jira/index.ts +11 -14
- package/core/integrations/jira/mcp-adapter.ts +5 -10
- package/core/integrations/jira/service.ts +10 -10
- package/core/integrations/linear/client.ts +27 -18
- package/core/integrations/linear/index.ts +9 -12
- package/core/integrations/linear/service.ts +11 -11
- package/core/integrations/linear/sync.ts +8 -8
- package/core/outcomes/analyzer.ts +5 -18
- package/core/outcomes/index.ts +2 -2
- package/core/outcomes/recorder.ts +3 -3
- package/core/plugin/builtin/webhook.ts +19 -15
- package/core/plugin/hooks.ts +29 -21
- package/core/plugin/index.ts +7 -7
- package/core/plugin/loader.ts +19 -19
- package/core/plugin/registry.ts +12 -23
- package/core/schemas/agents.ts +1 -1
- package/core/schemas/analysis.ts +1 -1
- package/core/schemas/enriched-task.ts +62 -49
- package/core/schemas/ideas.ts +13 -13
- package/core/schemas/index.ts +17 -27
- package/core/schemas/issues.ts +40 -25
- package/core/schemas/metrics.ts +25 -25
- package/core/schemas/outcomes.ts +70 -62
- package/core/schemas/permissions.ts +15 -12
- package/core/schemas/prd.ts +27 -14
- package/core/schemas/project.ts +3 -3
- package/core/schemas/roadmap.ts +47 -34
- package/core/schemas/schemas.ts +3 -4
- package/core/schemas/shipped.ts +3 -3
- package/core/schemas/state.ts +43 -29
- package/core/server/index.ts +5 -6
- package/core/server/routes-extended.ts +68 -72
- package/core/server/routes.ts +3 -3
- package/core/server/server.ts +31 -26
- package/core/services/agent-generator.ts +237 -0
- package/core/services/agent-service.ts +2 -2
- package/core/services/breakdown-service.ts +2 -4
- package/core/services/context-generator.ts +299 -0
- package/core/services/context-selector.ts +420 -0
- package/core/services/doctor-service.ts +426 -0
- package/core/services/file-categorizer.ts +448 -0
- package/core/services/file-scorer.ts +270 -0
- package/core/services/git-analyzer.ts +267 -0
- package/core/services/index.ts +27 -10
- package/core/services/memory-service.ts +3 -4
- package/core/services/project-index.ts +911 -0
- package/core/services/project-service.ts +4 -4
- package/core/services/skill-installer.ts +14 -17
- package/core/services/skill-lock.ts +3 -3
- package/core/services/skill-service.ts +12 -6
- package/core/services/stack-detector.ts +245 -0
- package/core/services/sync-service.ts +87 -345
- package/core/services/watch-service.ts +294 -0
- package/core/session/compaction.ts +23 -31
- package/core/session/index.ts +11 -5
- package/core/session/log-migration.ts +3 -3
- package/core/session/metrics.ts +19 -14
- package/core/session/session-log-manager.ts +12 -17
- package/core/session/task-session-manager.ts +25 -25
- package/core/session/utils.ts +1 -1
- package/core/storage/ideas-storage.ts +41 -57
- package/core/storage/index-storage.ts +514 -0
- package/core/storage/index.ts +41 -17
- package/core/storage/metrics-storage.ts +39 -34
- package/core/storage/queue-storage.ts +35 -45
- package/core/storage/shipped-storage.ts +17 -20
- package/core/storage/state-storage.ts +50 -30
- package/core/storage/storage-manager.ts +6 -6
- package/core/storage/storage.ts +18 -15
- package/core/sync/auth-config.ts +3 -3
- package/core/sync/index.ts +13 -19
- package/core/sync/oauth-handler.ts +3 -3
- package/core/sync/sync-client.ts +4 -9
- package/core/sync/sync-manager.ts +12 -14
- package/core/types/commands.ts +42 -7
- package/core/types/index.ts +284 -305
- package/core/types/integrations.ts +3 -3
- package/core/types/storage.ts +14 -14
- package/core/types/utils.ts +3 -3
- package/core/utils/agent-stream.ts +3 -1
- package/core/utils/animations.ts +14 -11
- package/core/utils/branding.ts +7 -7
- package/core/utils/cache.ts +1 -3
- package/core/utils/collection-filters.ts +3 -15
- package/core/utils/date-helper.ts +2 -7
- package/core/utils/file-helper.ts +13 -8
- package/core/utils/jsonl-helper.ts +13 -10
- package/core/utils/keychain.ts +4 -8
- package/core/utils/logger.ts +1 -1
- package/core/utils/next-steps.ts +3 -3
- package/core/utils/output.ts +58 -11
- package/core/utils/project-commands.ts +6 -6
- package/core/utils/project-credentials.ts +5 -12
- package/core/utils/runtime.ts +2 -2
- package/core/utils/session-helper.ts +3 -4
- package/core/utils/version.ts +3 -3
- package/core/wizard/index.ts +13 -0
- package/core/wizard/onboarding.ts +633 -0
- package/core/workflow/state-machine.ts +7 -7
- package/dist/bin/prjct.mjs +18755 -15574
- package/dist/core/infrastructure/command-installer.js +86 -79
- package/dist/core/infrastructure/editors-config.js +6 -6
- package/dist/core/infrastructure/setup.js +246 -225
- package/dist/core/utils/version.js +9 -9
- package/package.json +11 -12
- package/scripts/build.js +3 -3
- package/scripts/postinstall.js +2 -2
- package/templates/mcp-config.json +6 -1
- package/templates/permissions/permissive.jsonc +1 -1
- package/templates/permissions/strict.jsonc +5 -9
- package/templates/global/docs/agents.md +0 -88
- package/templates/global/docs/architecture.md +0 -103
- package/templates/global/docs/commands.md +0 -96
- 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
|
|
11
|
-
import
|
|
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
|
-
|
|
13
|
+
ApprovalContext,
|
|
27
14
|
ExecutionResult,
|
|
28
|
-
SimpleExecutionResult,
|
|
29
15
|
ExecutionToolsFn,
|
|
30
|
-
|
|
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(
|
|
154
|
-
reasoning = await chainOfThought.reason(
|
|
155
|
-
commandName,
|
|
148
|
+
const reasoningState = await contextBuilder.loadStateForCommand(
|
|
156
149
|
metadataContext,
|
|
157
|
-
|
|
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(
|
|
229
|
-
|
|
230
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
314
|
-
|
|
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(
|
|
317
|
-
|
|
318
|
-
|
|
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) =>
|
|
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) =>
|
|
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,
|
|
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([
|
|
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
|
|
15
|
-
import
|
|
16
|
-
import os from 'os'
|
|
17
|
-
import
|
|
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 (
|
|
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 &&
|
|
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 (
|
|
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(
|
|
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 {
|
package/core/agentic/index.ts
CHANGED
|
@@ -10,178 +10,171 @@
|
|
|
10
10
|
* - Tools: Tool registry, template loader
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
// ============
|
|
14
|
-
//
|
|
15
|
-
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
80
|
-
|
|
133
|
+
verifyNow,
|
|
134
|
+
verifyShip,
|
|
81
135
|
verifySpec,
|
|
82
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
{
|
|
52
|
-
|
|
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
|
-
{
|
|
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:
|
|
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(
|
|
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.`,
|