@vpxa/aikit 0.1.73 → 0.1.75

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 (142) hide show
  1. package/package.json +9 -1
  2. package/packages/cli/dist/index.js +2 -2
  3. package/packages/cli/dist/{init-D_OGLUN1.js → init-CuRXmyD9.js} +4 -4
  4. package/packages/cli/dist/scaffold-WMQ2uQ48.js +2 -0
  5. package/packages/cli/dist/{templates-DJ7EC5vw.js → templates-ArdAVWoY.js} +13 -3
  6. package/packages/cli/dist/user-vbJwa7x2.js +5 -0
  7. package/packages/dashboard/dist/assets/index-C6D-PCp0.js.map +1 -1
  8. package/packages/flows/dist/index.d.ts +29 -0
  9. package/packages/flows/dist/index.js +1 -1
  10. package/packages/server/dist/index.js +1 -1
  11. package/packages/server/dist/{server-B9Mx1aK-.js → server-CVhVH5cT.js} +127 -127
  12. package/packages/tools/dist/index.d.ts +19 -1
  13. package/packages/tools/dist/index.js +39 -39
  14. package/scaffold/dist/adapters/claude-code.mjs +4 -0
  15. package/scaffold/dist/adapters/copilot.mjs +75 -0
  16. package/scaffold/dist/adapters/flows.mjs +1 -0
  17. package/scaffold/dist/adapters/skills.mjs +1 -0
  18. package/scaffold/dist/compiled/flows-data.mjs +1429 -0
  19. package/scaffold/dist/compiled/skills-data.mjs +9951 -0
  20. package/scaffold/dist/definitions/agents.mjs +9 -0
  21. package/scaffold/{definitions → dist/definitions}/bodies.mjs +6 -229
  22. package/scaffold/dist/definitions/exclusions.mjs +1 -0
  23. package/scaffold/dist/definitions/hooks.mjs +1 -0
  24. package/scaffold/dist/definitions/models.mjs +1 -0
  25. package/scaffold/dist/definitions/plugins.mjs +1 -0
  26. package/scaffold/{definitions → dist/definitions}/prompts.mjs +9 -149
  27. package/scaffold/{definitions → dist/definitions}/protocols.mjs +9 -37
  28. package/scaffold/dist/definitions/tools.mjs +1 -0
  29. package/packages/cli/dist/scaffold-CJwkHf-q.js +0 -2
  30. package/packages/cli/dist/user-BEmVW8Tp.js +0 -5
  31. package/scaffold/adapters/claude-code.mjs +0 -73
  32. package/scaffold/adapters/copilot.mjs +0 -292
  33. package/scaffold/definitions/agents.mjs +0 -266
  34. package/scaffold/definitions/hooks.mjs +0 -43
  35. package/scaffold/definitions/models.mjs +0 -84
  36. package/scaffold/definitions/plugins.mjs +0 -147
  37. package/scaffold/definitions/tools.mjs +0 -250
  38. package/scaffold/flows/_epilogue/steps/docs-sync/README.md +0 -120
  39. package/scaffold/flows/aikit-advanced/README.md +0 -70
  40. package/scaffold/flows/aikit-advanced/flow.json +0 -69
  41. package/scaffold/flows/aikit-advanced/steps/design/README.md +0 -178
  42. package/scaffold/flows/aikit-advanced/steps/execute/README.md +0 -145
  43. package/scaffold/flows/aikit-advanced/steps/plan/README.md +0 -122
  44. package/scaffold/flows/aikit-advanced/steps/spec/README.md +0 -121
  45. package/scaffold/flows/aikit-advanced/steps/task/README.md +0 -119
  46. package/scaffold/flows/aikit-advanced/steps/verify/README.md +0 -145
  47. package/scaffold/flows/aikit-basic/README.md +0 -51
  48. package/scaffold/flows/aikit-basic/flow.json +0 -45
  49. package/scaffold/flows/aikit-basic/steps/assess/README.md +0 -109
  50. package/scaffold/flows/aikit-basic/steps/design/README.md +0 -116
  51. package/scaffold/flows/aikit-basic/steps/implement/README.md +0 -131
  52. package/scaffold/flows/aikit-basic/steps/verify/README.md +0 -123
  53. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +0 -132
  54. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +0 -132
  55. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +0 -112
  56. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +0 -112
  57. package/scaffold/general/agents/Debugger.agent.md +0 -412
  58. package/scaffold/general/agents/Documenter.agent.md +0 -468
  59. package/scaffold/general/agents/Explorer.agent.md +0 -76
  60. package/scaffold/general/agents/Frontend.agent.md +0 -440
  61. package/scaffold/general/agents/Implementer.agent.md +0 -425
  62. package/scaffold/general/agents/Orchestrator.agent.md +0 -452
  63. package/scaffold/general/agents/Planner.agent.md +0 -481
  64. package/scaffold/general/agents/README.md +0 -57
  65. package/scaffold/general/agents/Refactor.agent.md +0 -435
  66. package/scaffold/general/agents/Researcher-Alpha.agent.md +0 -151
  67. package/scaffold/general/agents/Researcher-Beta.agent.md +0 -152
  68. package/scaffold/general/agents/Researcher-Delta.agent.md +0 -153
  69. package/scaffold/general/agents/Researcher-Gamma.agent.md +0 -152
  70. package/scaffold/general/agents/Security.agent.md +0 -433
  71. package/scaffold/general/agents/_shared/architect-reviewer-base.md +0 -104
  72. package/scaffold/general/agents/_shared/code-agent-base.md +0 -366
  73. package/scaffold/general/agents/_shared/code-reviewer-base.md +0 -87
  74. package/scaffold/general/agents/_shared/decision-protocol.md +0 -27
  75. package/scaffold/general/agents/_shared/forge-protocol.md +0 -90
  76. package/scaffold/general/agents/_shared/researcher-base.md +0 -114
  77. package/scaffold/general/agents/templates/adr-template.md +0 -28
  78. package/scaffold/general/agents/templates/execution-state.md +0 -26
  79. package/scaffold/general/prompts/aikit-ask.prompt.md +0 -13
  80. package/scaffold/general/prompts/aikit-debug.prompt.md +0 -15
  81. package/scaffold/general/prompts/aikit-design.prompt.md +0 -15
  82. package/scaffold/general/prompts/aikit-flow-add.prompt.md +0 -84
  83. package/scaffold/general/prompts/aikit-flow-create.prompt.md +0 -80
  84. package/scaffold/general/prompts/aikit-flow-manage.prompt.md +0 -24
  85. package/scaffold/general/prompts/aikit-implement.prompt.md +0 -17
  86. package/scaffold/general/prompts/aikit-plan.prompt.md +0 -15
  87. package/scaffold/general/prompts/aikit-review.prompt.md +0 -24
  88. package/scaffold/general/skills/adr-skill/SKILL.md +0 -335
  89. package/scaffold/general/skills/adr-skill/assets/templates/adr-madr.md +0 -89
  90. package/scaffold/general/skills/adr-skill/assets/templates/adr-readme.md +0 -20
  91. package/scaffold/general/skills/adr-skill/assets/templates/adr-simple.md +0 -46
  92. package/scaffold/general/skills/adr-skill/references/adr-conventions.md +0 -95
  93. package/scaffold/general/skills/adr-skill/references/examples.md +0 -193
  94. package/scaffold/general/skills/adr-skill/references/review-checklist.md +0 -77
  95. package/scaffold/general/skills/adr-skill/references/template-variants.md +0 -52
  96. package/scaffold/general/skills/adr-skill/scripts/bootstrap_adr.js +0 -259
  97. package/scaffold/general/skills/adr-skill/scripts/new_adr.js +0 -391
  98. package/scaffold/general/skills/adr-skill/scripts/set_adr_status.js +0 -169
  99. package/scaffold/general/skills/aikit/SKILL.md +0 -754
  100. package/scaffold/general/skills/brainstorming/SKILL.md +0 -265
  101. package/scaffold/general/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  102. package/scaffold/general/skills/c4-architecture/SKILL.md +0 -389
  103. package/scaffold/general/skills/c4-architecture/references/advanced-patterns.md +0 -552
  104. package/scaffold/general/skills/c4-architecture/references/c4-syntax.md +0 -510
  105. package/scaffold/general/skills/c4-architecture/references/common-mistakes.md +0 -437
  106. package/scaffold/general/skills/c4-architecture/references/html-design-system.md +0 -337
  107. package/scaffold/general/skills/c4-architecture/references/html-template.html +0 -627
  108. package/scaffold/general/skills/docs/SKILL.md +0 -553
  109. package/scaffold/general/skills/docs/references/diataxis-anti-patterns.md +0 -147
  110. package/scaffold/general/skills/docs/references/diataxis-compass.md +0 -123
  111. package/scaffold/general/skills/docs/references/diataxis-quadrants.md +0 -192
  112. package/scaffold/general/skills/docs/references/diataxis-quality.md +0 -76
  113. package/scaffold/general/skills/docs/references/diataxis-templates.md +0 -120
  114. package/scaffold/general/skills/docs/references/flow-artifacts-guide.md +0 -70
  115. package/scaffold/general/skills/docs/references/project-knowledge-gotchas.md +0 -32
  116. package/scaffold/general/skills/docs/references/project-knowledge-templates.md +0 -281
  117. package/scaffold/general/skills/docs/references/project-knowledge-workflow.md +0 -80
  118. package/scaffold/general/skills/frontend-design/SKILL.md +0 -237
  119. package/scaffold/general/skills/lesson-learned/SKILL.md +0 -113
  120. package/scaffold/general/skills/lesson-learned/references/anti-patterns.md +0 -55
  121. package/scaffold/general/skills/lesson-learned/references/se-principles.md +0 -109
  122. package/scaffold/general/skills/multi-agents-development/SKILL.md +0 -448
  123. package/scaffold/general/skills/multi-agents-development/architecture-review-prompt.md +0 -81
  124. package/scaffold/general/skills/multi-agents-development/code-quality-review-prompt.md +0 -91
  125. package/scaffold/general/skills/multi-agents-development/implementer-prompt.md +0 -93
  126. package/scaffold/general/skills/multi-agents-development/parallel-dispatch-example.md +0 -167
  127. package/scaffold/general/skills/multi-agents-development/spec-review-prompt.md +0 -81
  128. package/scaffold/general/skills/present/SKILL.md +0 -616
  129. package/scaffold/general/skills/react/SKILL.md +0 -309
  130. package/scaffold/general/skills/repo-access/SKILL.md +0 -178
  131. package/scaffold/general/skills/repo-access/references/error-patterns.md +0 -116
  132. package/scaffold/general/skills/repo-access/references/platform-matrix.md +0 -142
  133. package/scaffold/general/skills/requirements-clarity/SKILL.md +0 -333
  134. package/scaffold/general/skills/session-handoff/SKILL.md +0 -199
  135. package/scaffold/general/skills/session-handoff/references/handoff-template.md +0 -139
  136. package/scaffold/general/skills/session-handoff/references/resume-checklist.md +0 -80
  137. package/scaffold/general/skills/session-handoff/scripts/check_staleness.js +0 -269
  138. package/scaffold/general/skills/session-handoff/scripts/create_handoff.js +0 -299
  139. package/scaffold/general/skills/session-handoff/scripts/list_handoffs.js +0 -113
  140. package/scaffold/general/skills/session-handoff/scripts/validate_handoff.js +0 -241
  141. package/scaffold/general/skills/typescript/SKILL.md +0 -405
  142. package/scaffold/generate.mjs +0 -82
@@ -1,139 +0,0 @@
1
- # Handoff Template
2
-
3
- Use this template structure when creating handoff documents. The smart scaffold script will pre-fill metadata sections; complete the remaining sections based on session context.
4
-
5
- ## Table of Contents
6
-
7
- - [Session Metadata](#session-metadata)
8
- - [Current State Summary](#current-state-summary)
9
- - [Codebase Understanding](#codebase-understanding)
10
- - [Architecture Overview](#architecture-overview)
11
- - [Critical Files](#critical-files)
12
- - [Key Patterns Discovered](#key-patterns-discovered)
13
- - [Work Completed](#work-completed)
14
- - [Tasks Finished](#tasks-finished)
15
- - [Files Modified](#files-modified)
16
- - [Decisions Made](#decisions-made)
17
- - [Pending Work](#pending-work)
18
- - [Immediate Next Steps](#immediate-next-steps)
19
- - [Blockers/Open Questions](#blockersopen-questions)
20
- - [Deferred Items](#deferred-items)
21
- - [Context for Resuming Agent](#context-for-resuming-agent)
22
- - [Important Context](#important-context)
23
- - [Assumptions Made](#assumptions-made)
24
- - [Potential Gotchas](#potential-gotchas)
25
- - [Environment State](#environment-state)
26
- - [Related Resources](#related-resources)
27
- - [Template Usage Notes](#template-usage-notes)
28
-
29
- ---
30
-
31
- # Handoff: [TASK_TITLE]
32
-
33
- ## Session Metadata
34
- - Created: [TIMESTAMP]
35
- - Project: [PROJECT_PATH]
36
- - Branch: [GIT_BRANCH]
37
- - Session duration: [APPROX_DURATION]
38
-
39
- ## Current State Summary
40
-
41
- [One paragraph: What was being worked on, current status, and where things left off]
42
-
43
- ## Codebase Understanding
44
-
45
- ### Architecture Overview
46
-
47
- [Key architectural insights discovered during this session - how the system is structured, main components, data flow]
48
-
49
- ### Critical Files
50
-
51
- | File | Purpose | Relevance |
52
- |------|---------|-----------|
53
- | path/to/file | What this file does | Why it matters for this task |
54
-
55
- ### Key Patterns Discovered
56
-
57
- [Important patterns, conventions, or idioms found in this codebase that the next agent should follow]
58
-
59
- ## Work Completed
60
-
61
- ### Tasks Finished
62
-
63
- - [x] Task 1 - brief description of what was done
64
- - [x] Task 2 - brief description
65
-
66
- ### Files Modified
67
-
68
- | File | Changes | Rationale |
69
- |------|---------|-----------|
70
- | path/to/file | Description of changes | Why this change was made |
71
-
72
- ### Decisions Made
73
-
74
- | Decision | Options Considered | Rationale |
75
- |----------|-------------------|-----------|
76
- | Chose X over Y | X, Y, Z | Why X was chosen |
77
-
78
- ## Pending Work
79
-
80
- ### Immediate Next Steps
81
-
82
- 1. [Most critical next action - what to do first]
83
- 2. [Second priority]
84
- 3. [Third priority]
85
-
86
- ### Blockers/Open Questions
87
-
88
- - [ ] Blocker: [description] - Needs: [what's required to unblock]
89
- - [ ] Question: [unclear aspect] - Suggested: [potential resolution]
90
-
91
- ### Deferred Items
92
-
93
- - Item 1 (deferred because: [reason, e.g., out of scope, needs user input])
94
-
95
- ## Context for Resuming Agent
96
-
97
- ### Important Context
98
-
99
- [Critical information the next agent MUST know to continue effectively - this is the most important section for handoff]
100
-
101
- ### Assumptions Made
102
-
103
- - Assumption 1: [what was assumed to be true]
104
- - Assumption 2: [another assumption]
105
-
106
- ### Potential Gotchas
107
-
108
- - [Things that might trip up a new agent - edge cases, quirks, non-obvious behavior]
109
-
110
- ## Environment State
111
-
112
- ### Tools/Services Used
113
-
114
- - [Tool/Service]: [relevant configuration or state]
115
-
116
- ### Active Processes
117
-
118
- - [Any background processes, dev servers, watchers that may be running]
119
-
120
- ### Environment Variables
121
-
122
- - [Key env vars that matter for this work - DO NOT include secrets/values, just names]
123
-
124
- ## Related Resources
125
-
126
- - [Link to relevant documentation]
127
- - [Related file paths]
128
- - [External resources consulted]
129
-
130
- ---
131
-
132
- ## Template Usage Notes
133
-
134
- When filling this template:
135
- 1. Be specific and concrete - vague descriptions don't help the next agent
136
- 2. Include file paths with line numbers where relevant (e.g., `src/auth.ts:142`)
137
- 3. Prioritize the "Important Context" and "Immediate Next Steps" sections
138
- 4. Don't include sensitive data (API keys, passwords, tokens)
139
- 5. Focus on WHAT and WHY, not just WHAT - rationale is crucial for handoffs
@@ -1,80 +0,0 @@
1
- # Resume Checklist
2
-
3
- Follow this checklist when resuming work from a handoff document to ensure zero-ambiguity continuation.
4
-
5
- ## Pre-Resume Verification
6
-
7
- - [ ] Read the entire handoff document before taking any action
8
- - [ ] Verify you are in the correct project directory
9
- - [ ] Confirm the git branch matches (or understand why it might differ)
10
- - [ ] Check the handoff timestamp - how stale is this context?
11
-
12
- ## Context Validation
13
-
14
- - [ ] Review "Important Context" section thoroughly
15
- - [ ] Understand all assumptions listed - are they still valid?
16
- - [ ] Check if any blockers have been resolved since handoff
17
- - [ ] Review "Potential Gotchas" to avoid known pitfalls
18
-
19
- ## State Verification
20
-
21
- - [ ] Run `git status` to see current file state
22
- - [ ] Compare modified files list in handoff vs current state
23
- - [ ] Check if any environment variables need to be set
24
- - [ ] Verify any required services/processes are running
25
-
26
- ## Resume Execution
27
-
28
- - [ ] Start with "Immediate Next Steps" item #1
29
- - [ ] Reference "Files Modified" table for context on recent changes
30
- - [ ] Apply patterns documented in "Key Patterns Discovered"
31
- - [ ] Follow architectural insights from "Architecture Overview"
32
-
33
- ## During Work
34
-
35
- - [ ] Update handoff document if major new context is discovered
36
- - [ ] Mark completed items in "Pending Work" as you finish them
37
- - [ ] Add new blockers/questions as they arise
38
- - [ ] Consider creating a new handoff if session becomes long
39
-
40
- ## Red Flags - Stop and Verify
41
-
42
- If you encounter any of these, pause and verify context before proceeding:
43
-
44
- 1. **Files mentioned in handoff don't exist** - codebase may have changed significantly
45
- 2. **Branch has diverged substantially** - check git log for recent commits
46
- 3. **Assumptions are clearly invalid** - reassess the approach
47
- 4. **Blockers marked as unresolved are now blocking you** - escalate to user
48
- 5. **Architecture has changed** - re-explore before continuing
49
-
50
- ## Quick Start Commands
51
-
52
- After reading the handoff, these commands help verify state:
53
-
54
- ```bash
55
- # Check current branch and status
56
- git branch --show-current
57
- git status
58
-
59
- # See recent commits (compare with handoff)
60
- git log --oneline -10
61
-
62
- # Check for any running processes mentioned
63
- ps aux | grep [process-name]
64
-
65
- # Verify environment
66
- env | grep [relevant-var]
67
- ```
68
-
69
- ## Handoff Quality Assessment
70
-
71
- Rate the handoff quality to identify if more exploration is needed:
72
-
73
- | Aspect | Good | Needs Exploration |
74
- |--------|------|-------------------|
75
- | Next steps | Clear, actionable | Vague or missing |
76
- | File references | Specific paths/lines | General descriptions |
77
- | Decisions | Rationale included | Just outcomes |
78
- | Context | Complete picture | Gaps or assumptions |
79
-
80
- If multiple aspects "Need Exploration", spend time re-exploring the codebase before continuing implementation.
@@ -1,269 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Check staleness of a handoff document compared to current project state.
4
- *
5
- * Analyzes:
6
- * - Time since handoff was created
7
- * - Git commits since handoff
8
- * - Files that changed since handoff
9
- * - Branch divergence
10
- * - Modified files status
11
- *
12
- * Usage:
13
- * node check_staleness.js <handoff-file>
14
- * node check_staleness.js .handoffs/2024-01-15-143022-auth.md
15
- */
16
-
17
- const fs = require('node:fs');
18
- const path = require('node:path');
19
- const { execSync } = require('node:child_process');
20
-
21
- function _die(msg) {
22
- process.stderr.write(`${msg}\n`);
23
- process.exit(1);
24
- }
25
-
26
- function runCmd(cmd, cwd) {
27
- try {
28
- return { ok: true, out: execSync(cmd, { cwd, timeout: 10_000, encoding: 'utf-8' }).trim() };
29
- } catch {
30
- return { ok: false, out: '' };
31
- }
32
- }
33
-
34
- function parseHandoffMetadata(filepath) {
35
- const content = fs.readFileSync(filepath, 'utf-8');
36
- const meta = { created: null, branch: null, projectPath: null, modifiedFiles: [] };
37
-
38
- const createdMatch = content.match(/Created:\s*(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})/);
39
- if (createdMatch) meta.created = new Date(createdMatch[1].replace(' ', 'T'));
40
-
41
- const branchMatch = content.match(/Branch:\s*(\S+)/);
42
- if (branchMatch && !branchMatch[1].startsWith('[')) meta.branch = branchMatch[1];
43
-
44
- const projMatch = content.match(/Project:\s*(.+?)(?:\n|$)/);
45
- if (projMatch) meta.projectPath = projMatch[1].trim();
46
-
47
- const fileMatches = content.matchAll(/\|\s*([a-zA-Z0-9_\-./]+\.[a-zA-Z]+)\s*\|/g);
48
- for (const m of fileMatches) {
49
- if (m[1].includes('/') && !m[1].startsWith('[')) meta.modifiedFiles.push(m[1]);
50
- }
51
-
52
- return meta;
53
- }
54
-
55
- function getCommitsSince(timestamp, cwd) {
56
- if (!timestamp) return [];
57
- const iso = timestamp.toISOString();
58
- const { ok, out } = runCmd(`git log --since="${iso}" --oneline --no-decorate`, cwd);
59
- return ok && out ? out.split('\n') : [];
60
- }
61
-
62
- function getChangedFilesSince(timestamp, cwd) {
63
- if (!timestamp) return [];
64
- const iso = timestamp.toISOString();
65
- const { ok, out } = runCmd(`git log --since="${iso}" --name-only --pretty=format:`, cwd);
66
- if (ok && out) {
67
- return [
68
- ...new Set(
69
- out
70
- .split('\n')
71
- .map((f) => f.trim())
72
- .filter(Boolean),
73
- ),
74
- ];
75
- }
76
- return [];
77
- }
78
-
79
- function checkFilesExist(files, cwd) {
80
- const existing = [];
81
- const missing = [];
82
- for (const f of files) {
83
- if (fs.existsSync(path.join(cwd, f))) existing.push(f);
84
- else missing.push(f);
85
- }
86
- return { existing, missing };
87
- }
88
-
89
- function calculateStaleness(daysOld, commitsSince, filesChanged, branchMatches, filesMissing) {
90
- const issues = [];
91
- let score = 0;
92
-
93
- if (daysOld > 30) {
94
- score += 3;
95
- issues.push(`Handoff is ${Math.floor(daysOld)} days old`);
96
- } else if (daysOld > 7) {
97
- score += 2;
98
- issues.push(`Handoff is ${Math.floor(daysOld)} days old`);
99
- } else if (daysOld > 1) {
100
- score += 1;
101
- }
102
-
103
- if (commitsSince > 50) {
104
- score += 3;
105
- issues.push(`${commitsSince} commits since handoff - significant changes`);
106
- } else if (commitsSince > 20) {
107
- score += 2;
108
- issues.push(`${commitsSince} commits since handoff`);
109
- } else if (commitsSince > 5) {
110
- score += 1;
111
- }
112
-
113
- if (!branchMatches) {
114
- score += 2;
115
- issues.push('Current branch differs from handoff branch');
116
- }
117
-
118
- if (filesMissing > 5) {
119
- score += 2;
120
- issues.push(`${filesMissing} referenced files no longer exist`);
121
- } else if (filesMissing > 0) {
122
- score += 1;
123
- issues.push(`${filesMissing} referenced file(s) missing`);
124
- }
125
-
126
- if (filesChanged > 20) {
127
- score += 2;
128
- issues.push(`${filesChanged} files changed since handoff`);
129
- } else if (filesChanged > 5) {
130
- score += 1;
131
- }
132
-
133
- let level, recommendation;
134
- if (score === 0) {
135
- level = 'FRESH';
136
- recommendation = 'Safe to resume - minimal changes since handoff';
137
- } else if (score <= 2) {
138
- level = 'SLIGHTLY_STALE';
139
- recommendation = 'Generally safe to resume - review changes before continuing';
140
- } else if (score <= 4) {
141
- level = 'STALE';
142
- recommendation = 'Proceed with caution - significant changes may affect context';
143
- } else {
144
- level = 'VERY_STALE';
145
- recommendation = 'Consider creating new handoff - too many changes since original';
146
- }
147
-
148
- return { level, recommendation, issues };
149
- }
150
-
151
- function checkStaleness(handoffPath) {
152
- if (!fs.existsSync(handoffPath)) return { error: `Handoff file not found: ${handoffPath}` };
153
-
154
- const meta = parseHandoffMetadata(handoffPath);
155
- const projectPath =
156
- meta.projectPath && fs.existsSync(meta.projectPath)
157
- ? meta.projectPath
158
- : path.resolve(path.dirname(handoffPath), '..'); // Up from .handoffs/
159
-
160
- const isGitRepo = runCmd('git rev-parse --git-dir', projectPath).ok;
161
-
162
- const result = {
163
- handoffFile: handoffPath,
164
- projectPath,
165
- isGitRepo,
166
- created: meta.created,
167
- handoffBranch: meta.branch,
168
- };
169
-
170
- if (meta.created) {
171
- const age = Date.now() - meta.created.getTime();
172
- result.daysOld = age / 86_400_000;
173
- result.hoursOld = age / 3_600_000;
174
- }
175
-
176
- if (isGitRepo) {
177
- const { out: currentBranch } = runCmd('git branch --show-current', projectPath);
178
- result.currentBranch = currentBranch;
179
- result.branchMatches = meta.branch ? currentBranch === meta.branch : true;
180
-
181
- const commits = getCommitsSince(meta.created, projectPath);
182
- result.commitsSince = commits.length;
183
- result.recentCommits = commits.slice(0, 5);
184
-
185
- const changedFiles = getChangedFilesSince(meta.created, projectPath);
186
- result.filesChangedCount = changedFiles.length;
187
- result.filesChanged = changedFiles.slice(0, 10);
188
-
189
- const { existing, missing } = checkFilesExist(meta.modifiedFiles, projectPath);
190
- result.referencedFilesExist = existing.length;
191
- result.referencedFilesMissing = missing;
192
-
193
- const { level, recommendation, issues } = calculateStaleness(
194
- result.daysOld || 0,
195
- result.commitsSince,
196
- result.filesChangedCount,
197
- result.branchMatches,
198
- missing.length,
199
- );
200
- result.stalenessLevel = level;
201
- result.recommendation = recommendation;
202
- result.issues = issues;
203
- } else {
204
- result.stalenessLevel = 'UNKNOWN';
205
- result.recommendation = 'Not a git repo - unable to detect changes';
206
- result.issues = ['Project is not a git repository'];
207
- }
208
-
209
- return result;
210
- }
211
-
212
- function printReport(result) {
213
- if (result.error) {
214
- console.log(`Error: ${result.error}`);
215
- return;
216
- }
217
-
218
- console.log(`\n${'='.repeat(60)}`);
219
- console.log('Handoff Staleness Report');
220
- console.log('='.repeat(60));
221
- console.log(`File: ${result.handoffFile}`);
222
- console.log(`Project: ${result.projectPath}`);
223
-
224
- if (result.created) {
225
- console.log(`Created: ${result.created.toISOString().replace('T', ' ').slice(0, 19)}`);
226
- if (result.daysOld != null) {
227
- console.log(
228
- result.daysOld < 1
229
- ? `Age: ${result.hoursOld.toFixed(1)} hours`
230
- : `Age: ${result.daysOld.toFixed(1)} days`,
231
- );
232
- }
233
- }
234
-
235
- console.log(`\nStaleness: ${result.stalenessLevel}`);
236
- console.log(`Recommendation: ${result.recommendation}`);
237
-
238
- if (result.issues && result.issues.length > 0) {
239
- console.log('\nIssues:');
240
- for (const issue of result.issues) console.log(` - ${issue}`);
241
- }
242
-
243
- if (result.isGitRepo) {
244
- console.log(
245
- `\nBranch: ${result.currentBranch || 'detached'}${result.branchMatches ? ' (matches handoff)' : ` (handoff: ${result.handoffBranch})`}`,
246
- );
247
- console.log(`Commits since handoff: ${result.commitsSince}`);
248
- console.log(`Files changed since handoff: ${result.filesChangedCount}`);
249
- if (result.referencedFilesMissing.length > 0) {
250
- console.log(`Missing referenced files: ${result.referencedFilesMissing.join(', ')}`);
251
- }
252
- }
253
- }
254
-
255
- // --- Main ---
256
- const args = process.argv.slice(2);
257
- if (args.includes('--help') || args.includes('-h') || args.length === 0) {
258
- console.log('Usage: node check_staleness.js <handoff-file>');
259
- console.log(' node check_staleness.js .handoffs/2024-01-15-143022-auth.md');
260
- process.exit(args.length === 0 ? 1 : 0);
261
- }
262
-
263
- if (args.includes('--json')) {
264
- const result = checkStaleness(args.find((a) => !a.startsWith('-')));
265
- console.log(JSON.stringify(result, null, 2));
266
- } else {
267
- const result = checkStaleness(args[0]);
268
- printReport(result);
269
- }