@relipa/ai-flow-kit 0.0.5-beta.0 → 0.0.5
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/README.md +23 -17
- package/custom/skills/{validate-ticket → read-study-requirement}/SKILL.md +27 -17
- package/custom/skills/review-plan/SKILL.md +1 -1
- package/custom/templates/shared/gate-workflow.md +88 -88
- package/custom/templates/tools/claude.md +1 -1
- package/custom/templates/tools/copilot.md +1 -1
- package/custom/templates/tools/cursor.md +1 -1
- package/custom/templates/tools/gemini.md +1 -1
- package/custom/templates/tools/generic.md +1 -1
- package/docs/{AIFLOW.md → common/AIFLOW.md} +462 -463
- package/docs/{CHANGELOG.md → common/CHANGELOG.md} +132 -128
- package/docs/{cli-reference.md → common/cli-reference.md} +1 -1
- package/docs/project/ARCHITECTURE.md +28 -0
- package/package.json +3 -2
- package/scripts/context.js +1 -1
- package/scripts/hooks/session-start.js +145 -145
- package/scripts/init.js +154 -47
- package/scripts/prompt.js +431 -402
- package/scripts/telemetry/cli.js +6 -12
- package/scripts/telemetry/config.js +1 -4
- package/scripts/telemetry/flush.js +16 -13
- package/scripts/use.js +74 -31
- package/docs/IMPLEMENTATION_SUMMARY.md +0 -330
- package/docs/architecture.md +0 -394
- package/docs/developer-overview.md +0 -126
- /package/docs/{QUICK_START.md → common/QUICK_START.md} +0 -0
- /package/docs/{ai-integration.md → common/ai-integration.md} +0 -0
- /package/docs/{configuration.md → common/configuration.md} +0 -0
- /package/docs/{getting-started.md → common/getting-started.md} +0 -0
- /package/docs/{troubleshooting.md → common/troubleshooting.md} +0 -0
- /package/docs/{workflows → common/workflows}/bug-fix.md +0 -0
- /package/docs/{workflows → common/workflows}/feature.md +0 -0
- /package/docs/{workflows → common/workflows}/impact-analysis.md +0 -0
- /package/docs/{workflows → common/workflows}/investigation.md +0 -0
- /package/docs/{workflows → common/workflows}/refactor.md +0 -0
|
@@ -1,128 +1,132 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to **@relipa/ai-flow-kit** will be documented in this file.
|
|
4
|
-
|
|
5
|
-
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
-
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## [0.0.4-beta.5] - 2026-04-21
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
- Created a dedicated `docs/` folder to house all developer-facing documentation.
|
|
14
|
-
- Integrated AI Skill Registry into all tool templates (Claude, Cursor, Gemini, Copilot) for better skill discovery.
|
|
15
|
-
|
|
16
|
-
### Changed
|
|
17
|
-
- Moved `README.md`, `QUICK_START.md`, `AIFLOW.md`, `CHANGELOG.md`, and `IMPLEMENTATION_SUMMARY.md` into the `docs/` directory.
|
|
18
|
-
- Updated `package.json` to exclude internal-only files (`CONTRIBUTING.md`, `plan.md`) from the NPM package distribution.
|
|
19
|
-
- Updated `scripts/init.js` to source documentation from the new `docs/` location.
|
|
20
|
-
- Updated all internal documentation links to reflect the new directory structure.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## [0.0.5-beta.0] - 2026-04-23
|
|
25
|
-
|
|
26
|
-
### Added
|
|
27
|
-
- **`aiflow gate <n> <action>` command** — Called automatically by AI during gate transitions. Supports `start` and `approved` actions for gates 1-5. Options: `--ticket <id>`, `--ai-tool <tool>`.
|
|
28
|
-
- **Telemetry gate logging** — Gate workflow templates now emit `aiflow gate N start/approved --ticket [id]` telemetry calls at each gate transition for usage metrics.
|
|
29
|
-
- **`aiflow telemetry flush` command** — Force-sends buffered telemetry events immediately.
|
|
30
|
-
|
|
31
|
-
### Changed
|
|
32
|
-
-
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
- **`
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- `aiflow
|
|
77
|
-
|
|
78
|
-
- `aiflow
|
|
79
|
-
- `aiflow
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
- **Gate
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
- `
|
|
95
|
-
- `
|
|
96
|
-
- `
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
106
|
-
- `
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
aiflow update
|
|
128
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to **@relipa/ai-flow-kit** will be documented in this file.
|
|
4
|
+
|
|
5
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
+
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.0.4-beta.5] - 2026-04-21
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Created a dedicated `docs/` folder to house all developer-facing documentation.
|
|
14
|
+
- Integrated AI Skill Registry into all tool templates (Claude, Cursor, Gemini, Copilot) for better skill discovery.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Moved `README.md`, `QUICK_START.md`, `AIFLOW.md`, `CHANGELOG.md`, and `IMPLEMENTATION_SUMMARY.md` into the `docs/` directory.
|
|
18
|
+
- Updated `package.json` to exclude internal-only files (`CONTRIBUTING.md`, `plan.md`) from the NPM package distribution.
|
|
19
|
+
- Updated `scripts/init.js` to source documentation from the new `docs/` location.
|
|
20
|
+
- Updated all internal documentation links to reflect the new directory structure.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## [0.0.5-beta.0] - 2026-04-23
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **`aiflow gate <n> <action>` command** — Called automatically by AI during gate transitions. Supports `start` and `approved` actions for gates 1-5. Options: `--ticket <id>`, `--ai-tool <tool>`.
|
|
28
|
+
- **Telemetry gate logging** — Gate workflow templates now emit `aiflow gate N start/approved --ticket [id]` telemetry calls at each gate transition for usage metrics.
|
|
29
|
+
- **`aiflow telemetry flush` command** — Force-sends buffered telemetry events immediately.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- **`aiflow init` safe overwrite flow** — When a project already has `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, etc., `aiflow init` now prompts before overwriting:
|
|
33
|
+
- **No (default):** keeps existing file untouched; saves the aiflow template to `.aiflow/reference/<file>` for manual comparison/merge.
|
|
34
|
+
- **Yes:** backs up the existing file to `.aiflow/backup/<file>` before overwriting — nothing is permanently lost.
|
|
35
|
+
- **`aiflow use --manual` pre-fill (Edit mode)** — Re-running `aiflow use --manual` when context already exists now pre-fills all fields (Ticket ID, Title, Description, Task type) with the current values; press Enter on any field to keep it unchanged.
|
|
36
|
+
- **Fix TEAM_SECRET input** — Replaced `password()` prompt with `input()` using a masked hint `[Reli***!@#]`; pressing Enter retains the existing value.
|
|
37
|
+
- **Fix Apps Script URL input** — Same pattern as TEAM_SECRET: masked hint `[https://script.google.com/macros/s/AKfy***xxxx/exec]`; pressing Enter retains the existing value.
|
|
38
|
+
- **Downgrade dependencies for Node >=16 compatibility** — `@inquirer/prompts` downgraded from `^8.3.2` to `^3.0.0`; `commander` downgraded from `^14.0.3` to `^11.0.0`.
|
|
39
|
+
- **`engines.node`** updated from `>=14.0.0` to `>=16.0.0`.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## [0.0.5] - 2026-04-23
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
- **Telemetry System (MVP)**: Added anonymous usage tracking to measure command metrics and user adoption.
|
|
47
|
+
- `aiflow telemetry enable/disable/status` commands to easily opt-in or opt-out.
|
|
48
|
+
- Automatically captures environment metadata and Git email via `git config --global user.email`.
|
|
49
|
+
- Secure payload signing natively using Node `crypto` HMAC-SHA256 to ensure data authenticity.
|
|
50
|
+
- Asynchronous payload flusher to ensure zero impact on command execution time (`< 5ms` overhead).
|
|
51
|
+
- Support tracking for multiple AI platforms including Cursor and Gemini via Command Execution events and the new Telemetry SDK.
|
|
52
|
+
|
|
53
|
+
### Security
|
|
54
|
+
- **Strict Privacy**: Explicitly removed all prompt content and chat history tracking to ensure 100% confidentiality of company code and PII.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## [Unreleased]
|
|
59
|
+
|
|
60
|
+
## [0.0.3-beta.0] - 2026-04-13
|
|
61
|
+
### Security
|
|
62
|
+
- Removed internal GitLab repository links and tracking information.
|
|
63
|
+
- Cleaned `.npmrc` configuration.
|
|
64
|
+
- Added helper scripts for beta and stable releases.
|
|
65
|
+
|
|
66
|
+
## [0.0.2] - 2026-04-13
|
|
67
|
+
### Changed
|
|
68
|
+
- Updated package to scoped name `@relipa/ai-flow-kit` in documentation and configuration.
|
|
69
|
+
- Fixed installation guides in README and QUICK_START.
|
|
70
|
+
|
|
71
|
+
## [0.0.1] - 2026-04-13 — Initial Release
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
|
|
75
|
+
#### CLI (`aiflow`)
|
|
76
|
+
- `aiflow init` — scaffold AI workflow config into any project
|
|
77
|
+
(supports `--framework` spring-boot/reactjs, `--adapter` jira/backlog)
|
|
78
|
+
- `aiflow use <skill>` — activate a custom skill in the current project
|
|
79
|
+
- `aiflow remove` — cleanly remove `ai-flow-kit` scaffolding from a project
|
|
80
|
+
- `aiflow guide` — interactive onboarding guide
|
|
81
|
+
- `aiflow update` — sync upstream skill/hook updates
|
|
82
|
+
- `aiflow doctor` — validate config, detect missing keys, report issues
|
|
83
|
+
- `aiflow --version` — print installed version
|
|
84
|
+
|
|
85
|
+
#### 5-Gate AI Workflow
|
|
86
|
+
- **Gate 1 — AI Analyze Requirement**: Auto-starts when a ticket context exists
|
|
87
|
+
in `.aiflow/context/current.json`; outputs `plan/[ticket-id]/requirement.md`
|
|
88
|
+
- **Gate 2 — Implementation Plan**: TDD plan generation, gated by `APPROVED`
|
|
89
|
+
- **Gate 3 — Code Generation**: TDD-only, test-first discipline enforced
|
|
90
|
+
- **Gate 4 — AI Self-Review**: Verification + impact analysis + checklist, gated by `APPROVED`
|
|
91
|
+
- **Gate 5 — Peer Review & PR**: Guided PR creation via `requesting-code-review` skill
|
|
92
|
+
|
|
93
|
+
#### Custom Skills (7 skills)
|
|
94
|
+
- `read-study-requirement` — Gate 1 requirement analysis with clarifying Q&A loop
|
|
95
|
+
- `generate-spec` — Gate 2 TDD implementation spec generator
|
|
96
|
+
- `impact-analysis` — breaking-change and dependency impact assessment
|
|
97
|
+
- `investigate-bug` — systematic bug investigation (reproduce → root cause → fix)
|
|
98
|
+
- `report-customer` — customer-facing incident report generator
|
|
99
|
+
- `review-plan` — Gate 4 self-review orchestrator
|
|
100
|
+
- `figma-to-component` — Figma design → UI component code generator
|
|
101
|
+
|
|
102
|
+
#### Multi-AI Support
|
|
103
|
+
- **Claude Code** integration via `CLAUDE.md` + `.claude/` directory structure
|
|
104
|
+
- **Gemini CLI** integration via `GEMINI.md`
|
|
105
|
+
- **GitHub Copilot** integration via agents config
|
|
106
|
+
- Superpowers skill library bundled as `upstream/` (pinned to v5.0.5)
|
|
107
|
+
|
|
108
|
+
#### Project Templates
|
|
109
|
+
- `AIFLOW.md` — team workflow reference document
|
|
110
|
+
- `QUICK_START.md` — 5-minute setup guide
|
|
111
|
+
- `.aiflowrc.json.example` — configuration file reference
|
|
112
|
+
|
|
113
|
+
### Architecture Notes
|
|
114
|
+
- Stateless per-ticket design — no persistent memory across sessions (planned: v0.1.x)
|
|
115
|
+
- Manual skill sync model via `aiflow use` (managed `aiflow skill` CLI planned: v0.1.x)
|
|
116
|
+
- Spring Boot (Java 17+) used as the reference framework in `CLAUDE.md` coding rules
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## How to upgrade
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm install -g @relipa/ai-flow-kit@latest
|
|
124
|
+
aiflow --version
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
After upgrading, run `aiflow update` inside your project to sync the latest skills and hooks:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
cd your-project
|
|
131
|
+
aiflow update
|
|
132
|
+
```
|
|
@@ -237,7 +237,7 @@ aiflow context --show
|
|
|
237
237
|
|
|
238
238
|
**What it does:**
|
|
239
239
|
1. Lists, saves, loads, or deletes contexts
|
|
240
|
-
2. Manages context history in `.
|
|
240
|
+
2. Manages context history in `.aiflow/context/history/`
|
|
241
241
|
3. Makes it easy to switch between tasks
|
|
242
242
|
|
|
243
243
|
**Example:**
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
> **Template file** — Replace this with your project's actual architecture.
|
|
4
|
+
|
|
5
|
+
## System Architecture
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
[Describe your system layers here]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Tech Stack
|
|
12
|
+
|
|
13
|
+
| Layer | Technology |
|
|
14
|
+
|-------|-----------|
|
|
15
|
+
| Backend | |
|
|
16
|
+
| Frontend | |
|
|
17
|
+
| Database | |
|
|
18
|
+
| Infrastructure | |
|
|
19
|
+
|
|
20
|
+
## Key Components
|
|
21
|
+
|
|
22
|
+
-
|
|
23
|
+
|
|
24
|
+
## Data Flow
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
[Describe main data flows]
|
|
28
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relipa/ai-flow-kit",
|
|
3
|
-
"version": "0.0.5
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "All-in-one AI Flow Kit for team development with Claude AI - skills, templates, and MCP adapters",
|
|
5
5
|
"author": "Relipa AI Team",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"custom",
|
|
20
20
|
"scripts",
|
|
21
21
|
"upstream",
|
|
22
|
-
"docs",
|
|
22
|
+
"docs/common",
|
|
23
|
+
"docs/project",
|
|
23
24
|
"package.json",
|
|
24
25
|
"index.js"
|
|
25
26
|
],
|
package/scripts/context.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
|
|
5
5
|
const PROJECT_DIR = process.cwd();
|
|
6
|
-
const CONTEXT_DIR = path.join(PROJECT_DIR, '.
|
|
6
|
+
const CONTEXT_DIR = path.join(PROJECT_DIR, '.aiflow', 'context');
|
|
7
7
|
const HISTORY_DIR = path.join(CONTEXT_DIR, 'history');
|
|
8
8
|
const CURRENT_FILE = path.join(CONTEXT_DIR, 'current.json');
|
|
9
9
|
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* SessionStart hook for ai-flow-kit
|
|
4
|
-
* Injects:
|
|
5
|
-
* 1. using-superpowers skill content
|
|
6
|
-
* 2. Active ticket context + gate workflow (if context exists)
|
|
7
|
-
* Cross-platform replacement for the bash session-start hook.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const { record } = require('../telemetry/record');
|
|
13
|
-
|
|
14
|
-
// Record session start telemetry
|
|
15
|
-
record('session.start');
|
|
16
|
-
|
|
17
|
-
// This script lives at .claude/hooks/session-start.js
|
|
18
|
-
// Project root is
|
|
19
|
-
const projectRoot = path.resolve(__dirname, '..', '..'
|
|
20
|
-
const skillPath = path.join(projectRoot, '.claude', 'skills', 'using-superpowers', 'SKILL.md');
|
|
21
|
-
const contextPath = path.join(projectRoot, '.aiflow', 'context', 'current.json');
|
|
22
|
-
|
|
23
|
-
// ── 1. Load superpowers skill ──────────────────────────────────
|
|
24
|
-
let skillContent = '';
|
|
25
|
-
try {
|
|
26
|
-
skillContent = fs.readFileSync(skillPath, 'utf-8');
|
|
27
|
-
} catch (_) {
|
|
28
|
-
// Skill file missing — continue without it
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// ── 2. Load active ticket context ──────────────────────────────
|
|
32
|
-
let contextBlock = '';
|
|
33
|
-
try {
|
|
34
|
-
if (fs.existsSync(contextPath)) {
|
|
35
|
-
const ctx = JSON.parse(fs.readFileSync(contextPath, 'utf-8'));
|
|
36
|
-
if (ctx.taskId && ctx.title) {
|
|
37
|
-
contextBlock = buildContextPrompt(ctx);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} catch (_) {
|
|
41
|
-
// Context missing or invalid — continue without it
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ── 3. Combine and output ──────────────────────────────────────
|
|
45
|
-
const parts = [];
|
|
46
|
-
|
|
47
|
-
if (skillContent) {
|
|
48
|
-
parts.push(`<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${skillContent}\n\n</EXTREMELY_IMPORTANT>`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (contextBlock) {
|
|
52
|
-
parts.push(contextBlock);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const combined = parts.join('\n\n');
|
|
56
|
-
|
|
57
|
-
// Escape for JSON string embedding
|
|
58
|
-
const escaped = combined
|
|
59
|
-
.replace(/\\/g, '\\\\')
|
|
60
|
-
.replace(/"/g, '\\"')
|
|
61
|
-
.replace(/\n/g, '\\n')
|
|
62
|
-
.replace(/\r/g, '\\r')
|
|
63
|
-
.replace(/\t/g, '\\t');
|
|
64
|
-
|
|
65
|
-
process.stdout.write(JSON.stringify({
|
|
66
|
-
hookSpecificOutput: {
|
|
67
|
-
hookEventName: 'SessionStart',
|
|
68
|
-
additionalContext: escaped
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
process.exit(0);
|
|
73
|
-
|
|
74
|
-
// ── Helper ─────────────────────────────────────────────────────
|
|
75
|
-
|
|
76
|
-
function buildContextPrompt(ctx) {
|
|
77
|
-
const taskType = ctx.taskType || 'feature';
|
|
78
|
-
|
|
79
|
-
const lines = [];
|
|
80
|
-
lines.push('<ACTIVE_TASK>');
|
|
81
|
-
lines.push(`**Active Ticket:** ${ctx.taskId} — ${ctx.title}`);
|
|
82
|
-
lines.push(`**Type:** ${taskType}`);
|
|
83
|
-
lines.push(`**Status:** ${ctx.status || 'Unknown'}`);
|
|
84
|
-
lines.push(`**Assignee:** ${ctx.assignee || 'Unknown'}`);
|
|
85
|
-
lines.push('');
|
|
86
|
-
|
|
87
|
-
if (ctx.description) {
|
|
88
|
-
lines.push('**Description:**');
|
|
89
|
-
lines.push(ctx.description.substring(0, 2000));
|
|
90
|
-
lines.push('');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (ctx.acceptanceCriteria && ctx.acceptanceCriteria.length > 0) {
|
|
94
|
-
lines.push('**Acceptance Criteria:**');
|
|
95
|
-
for (const c of ctx.acceptanceCriteria) {
|
|
96
|
-
lines.push(`- ${c}`);
|
|
97
|
-
}
|
|
98
|
-
lines.push('');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (ctx.comments && ctx.comments.length > 0) {
|
|
102
|
-
lines.push(`**Comments (${ctx.comments.length}):**`);
|
|
103
|
-
// Include last 5 comments to keep context manageable
|
|
104
|
-
const recent = ctx.comments.slice(-5);
|
|
105
|
-
for (const c of recent) {
|
|
106
|
-
lines.push(c);
|
|
107
|
-
lines.push('');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (ctx.context && ctx.context.files && ctx.context.files.length > 0) {
|
|
112
|
-
lines.push('**Related Files:**');
|
|
113
|
-
for (const f of ctx.context.files) {
|
|
114
|
-
lines.push(`- \`${f}\``);
|
|
115
|
-
}
|
|
116
|
-
lines.push('');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ── Gate workflow instruction ──
|
|
120
|
-
lines.push('---');
|
|
121
|
-
lines.push('');
|
|
122
|
-
lines.push('**AUTO-START GATE 1: You MUST begin analyzing this ticket immediately.**');
|
|
123
|
-
lines.push('');
|
|
124
|
-
lines.push(`INVOKE the \`
|
|
125
|
-
lines.push('');
|
|
126
|
-
lines.push('Gate 1 process:');
|
|
127
|
-
lines.push('1. Read the ticket context above');
|
|
128
|
-
lines.push('2. Read CLAUDE.md — understand project architecture and conventions');
|
|
129
|
-
lines.push('3. Read source code — identify related files, data flow, patterns');
|
|
130
|
-
lines.push('4. If anything is unclear — ask ONE question at a time');
|
|
131
|
-
lines.push('5. Output plan/' + ctx.taskId + '/requirement.md with:');
|
|
132
|
-
lines.push(' - Requirements summary');
|
|
133
|
-
lines.push(' - Source code analysis');
|
|
134
|
-
lines.push(' - Proposed solution and approach');
|
|
135
|
-
lines.push(' - Impact analysis');
|
|
136
|
-
lines.push(' - Effort estimate');
|
|
137
|
-
lines.push(' - Testing plan');
|
|
138
|
-
lines.push('6. Display GATE 1 prompt and wait for APPROVED');
|
|
139
|
-
lines.push('');
|
|
140
|
-
lines.push('DO NOT wait for the developer to ask. START NOW.');
|
|
141
|
-
lines.push('If you have not started automatically, begin as soon as the developer types **"start"**.');
|
|
142
|
-
lines.push('</ACTIVE_TASK>');
|
|
143
|
-
|
|
144
|
-
return lines.join('\n');
|
|
145
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* SessionStart hook for ai-flow-kit
|
|
4
|
+
* Injects:
|
|
5
|
+
* 1. using-superpowers skill content
|
|
6
|
+
* 2. Active ticket context + gate workflow (if context exists)
|
|
7
|
+
* Cross-platform replacement for the bash session-start hook.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { record } = require('../telemetry/record');
|
|
13
|
+
|
|
14
|
+
// Record session start telemetry
|
|
15
|
+
record('session.start');
|
|
16
|
+
|
|
17
|
+
// This script lives at .claude/hooks/session-start.js
|
|
18
|
+
// Project root is 2 levels up from __dirname (.claude/hooks → .claude → project root)
|
|
19
|
+
const projectRoot = path.resolve(__dirname, '..', '..');
|
|
20
|
+
const skillPath = path.join(projectRoot, '.claude', 'skills', 'using-superpowers', 'SKILL.md');
|
|
21
|
+
const contextPath = path.join(projectRoot, '.aiflow', 'context', 'current.json');
|
|
22
|
+
|
|
23
|
+
// ── 1. Load superpowers skill ──────────────────────────────────
|
|
24
|
+
let skillContent = '';
|
|
25
|
+
try {
|
|
26
|
+
skillContent = fs.readFileSync(skillPath, 'utf-8');
|
|
27
|
+
} catch (_) {
|
|
28
|
+
// Skill file missing — continue without it
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ── 2. Load active ticket context ──────────────────────────────
|
|
32
|
+
let contextBlock = '';
|
|
33
|
+
try {
|
|
34
|
+
if (fs.existsSync(contextPath)) {
|
|
35
|
+
const ctx = JSON.parse(fs.readFileSync(contextPath, 'utf-8'));
|
|
36
|
+
if (ctx.taskId && ctx.title) {
|
|
37
|
+
contextBlock = buildContextPrompt(ctx);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch (_) {
|
|
41
|
+
// Context missing or invalid — continue without it
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ── 3. Combine and output ──────────────────────────────────────
|
|
45
|
+
const parts = [];
|
|
46
|
+
|
|
47
|
+
if (skillContent) {
|
|
48
|
+
parts.push(`<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${skillContent}\n\n</EXTREMELY_IMPORTANT>`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (contextBlock) {
|
|
52
|
+
parts.push(contextBlock);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const combined = parts.join('\n\n');
|
|
56
|
+
|
|
57
|
+
// Escape for JSON string embedding
|
|
58
|
+
const escaped = combined
|
|
59
|
+
.replace(/\\/g, '\\\\')
|
|
60
|
+
.replace(/"/g, '\\"')
|
|
61
|
+
.replace(/\n/g, '\\n')
|
|
62
|
+
.replace(/\r/g, '\\r')
|
|
63
|
+
.replace(/\t/g, '\\t');
|
|
64
|
+
|
|
65
|
+
process.stdout.write(JSON.stringify({
|
|
66
|
+
hookSpecificOutput: {
|
|
67
|
+
hookEventName: 'SessionStart',
|
|
68
|
+
additionalContext: escaped
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
process.exit(0);
|
|
73
|
+
|
|
74
|
+
// ── Helper ─────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
function buildContextPrompt(ctx) {
|
|
77
|
+
const taskType = ctx.taskType || 'feature';
|
|
78
|
+
|
|
79
|
+
const lines = [];
|
|
80
|
+
lines.push('<ACTIVE_TASK>');
|
|
81
|
+
lines.push(`**Active Ticket:** ${ctx.taskId} — ${ctx.title}`);
|
|
82
|
+
lines.push(`**Type:** ${taskType}`);
|
|
83
|
+
lines.push(`**Status:** ${ctx.status || 'Unknown'}`);
|
|
84
|
+
lines.push(`**Assignee:** ${ctx.assignee || 'Unknown'}`);
|
|
85
|
+
lines.push('');
|
|
86
|
+
|
|
87
|
+
if (ctx.description) {
|
|
88
|
+
lines.push('**Description:**');
|
|
89
|
+
lines.push(ctx.description.substring(0, 2000));
|
|
90
|
+
lines.push('');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (ctx.acceptanceCriteria && ctx.acceptanceCriteria.length > 0) {
|
|
94
|
+
lines.push('**Acceptance Criteria:**');
|
|
95
|
+
for (const c of ctx.acceptanceCriteria) {
|
|
96
|
+
lines.push(`- ${c}`);
|
|
97
|
+
}
|
|
98
|
+
lines.push('');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (ctx.comments && ctx.comments.length > 0) {
|
|
102
|
+
lines.push(`**Comments (${ctx.comments.length}):**`);
|
|
103
|
+
// Include last 5 comments to keep context manageable
|
|
104
|
+
const recent = ctx.comments.slice(-5);
|
|
105
|
+
for (const c of recent) {
|
|
106
|
+
lines.push(c);
|
|
107
|
+
lines.push('');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (ctx.context && ctx.context.files && ctx.context.files.length > 0) {
|
|
112
|
+
lines.push('**Related Files:**');
|
|
113
|
+
for (const f of ctx.context.files) {
|
|
114
|
+
lines.push(`- \`${f}\``);
|
|
115
|
+
}
|
|
116
|
+
lines.push('');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ── Gate workflow instruction ──
|
|
120
|
+
lines.push('---');
|
|
121
|
+
lines.push('');
|
|
122
|
+
lines.push('**AUTO-START GATE 1: You MUST begin analyzing this ticket immediately.**');
|
|
123
|
+
lines.push('');
|
|
124
|
+
lines.push(`INVOKE the \`read-study-requirement\` skill NOW for ticket ${ctx.taskId}.`);
|
|
125
|
+
lines.push('');
|
|
126
|
+
lines.push('Gate 1 process:');
|
|
127
|
+
lines.push('1. Read the ticket context above');
|
|
128
|
+
lines.push('2. Read CLAUDE.md — understand project architecture and conventions');
|
|
129
|
+
lines.push('3. Read source code — identify related files, data flow, patterns');
|
|
130
|
+
lines.push('4. If anything is unclear — ask ONE question at a time');
|
|
131
|
+
lines.push('5. Output plan/' + ctx.taskId + '/requirement.md with:');
|
|
132
|
+
lines.push(' - Requirements summary');
|
|
133
|
+
lines.push(' - Source code analysis');
|
|
134
|
+
lines.push(' - Proposed solution and approach');
|
|
135
|
+
lines.push(' - Impact analysis');
|
|
136
|
+
lines.push(' - Effort estimate');
|
|
137
|
+
lines.push(' - Testing plan');
|
|
138
|
+
lines.push('6. Display GATE 1 prompt and wait for APPROVED');
|
|
139
|
+
lines.push('');
|
|
140
|
+
lines.push('DO NOT wait for the developer to ask. START NOW.');
|
|
141
|
+
lines.push('If you have not started automatically, begin as soon as the developer types **"start"**.');
|
|
142
|
+
lines.push('</ACTIVE_TASK>');
|
|
143
|
+
|
|
144
|
+
return lines.join('\n');
|
|
145
|
+
}
|