plankit-cli 1.0.0

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 ADDED
@@ -0,0 +1,71 @@
1
+ # `plankit` — AI Coding Agent Workflow Command Suite
2
+
3
+ > [!IMPORTANT]
4
+ > **PlanKit CLI** is a lightweight, zero-dependency command-line tool that installs the **PlanKit Command Suite** (`plankit.plan`, `plankit.clarify`, `plankit.implement`, `plankit.review`) into any project. Works seamlessly with **Google Antigravity**, **OpenCode**, **Codex**, **Cursor**, and **Claude Code**.
5
+
6
+ ---
7
+
8
+ ## Quick Start (Usage without installation)
9
+
10
+ Run in any project directory:
11
+
12
+ ```bash
13
+ npx plankit-cli init
14
+ ```
15
+
16
+ This single command sets up all required configuration files and folders:
17
+ - `artifacts/current/` & `artifacts/archived/`
18
+ - `artifacts/PLANKIT.md` (Specification)
19
+ - `.gemini/instructions.md` (Antigravity binding)
20
+ - `.opencode/commands/*.md` (OpenCode Markdown custom commands)
21
+ - `.cursorrules` (Cursor rules)
22
+ - `AGENTS.md` (Codex / Claude Code universal instructions)
23
+
24
+ ---
25
+
26
+ ## Global Installation (Optional)
27
+
28
+ Install globally using `npm`:
29
+
30
+ ```bash
31
+ npm install -g plankit-cli
32
+ ```
33
+
34
+ Then run anywhere:
35
+
36
+ ```bash
37
+ plankit init
38
+ plankit plan <feature-name>
39
+ plankit status
40
+ plankit archive <feature-name>
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Commands Summary
46
+
47
+ | Command | Action |
48
+ |---|---|
49
+ | `plankit init` | Scaffolds PlanKit configs & folders in the current directory. |
50
+ | `plankit plan <feature>` | Scaffolds a new feature workspace under `artifacts/current/<feature>/`. |
51
+ | `plankit status` | Lists all active and archived features. |
52
+ | `plankit archive <feature>` | Moves a completed feature to `artifacts/archived/<feature>/`. |
53
+
54
+ ---
55
+
56
+ ## Publishing to NPM
57
+
58
+ To publish this package to the official NPM registry so anyone in the world can run `npx plankit init`:
59
+
60
+ 1. Log in to your NPM account:
61
+ ```bash
62
+ npm login
63
+ ```
64
+ 2. Navigate to the `packages/plankit` directory:
65
+ ```bash
66
+ cd packages/plankit
67
+ ```
68
+ 3. Publish to NPM:
69
+ ```bash
70
+ npm publish --access public
71
+ ```
package/bin/plankit.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runCli } from '../src/cli.js';
4
+
5
+ runCli(process.argv.slice(2));
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "plankit-cli",
3
+ "version": "1.0.0",
4
+ "description": "PlanKit Command Suite CLI for AI Coding Assistants (Antigravity, OpenCode, Codex, Cursor)",
5
+ "main": "src/cli.js",
6
+ "bin": {
7
+ "plankit": "bin/plankit.js"
8
+ },
9
+ "type": "module",
10
+ "scripts": {
11
+ "start": "node bin/plankit.js",
12
+ "test": "node --test"
13
+ },
14
+ "keywords": [
15
+ "plankit",
16
+ "ai-agent",
17
+ "antigravity",
18
+ "opencode",
19
+ "codex",
20
+ "cursor",
21
+ "workflow",
22
+ "cli"
23
+ ],
24
+ "author": "",
25
+ "license": "MIT"
26
+ }
package/src/cli.js ADDED
@@ -0,0 +1,235 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import os from 'node:os';
4
+ import {
5
+ AGENTS_MD_TEMPLATE,
6
+ CURSORRULES_TEMPLATE,
7
+ GEMINI_INSTRUCTIONS_TEMPLATE,
8
+ OPENCODE_COMMAND_PLAN,
9
+ OPENCODE_COMMAND_CLARIFY,
10
+ OPENCODE_COMMAND_IMPLEMENT,
11
+ OPENCODE_COMMAND_REVIEW,
12
+ OPENCODE_COMMAND_MASTER,
13
+ PLANKIT_SPEC_TEMPLATE
14
+ } from './templates.js';
15
+
16
+ export function runCli(args) {
17
+ const command = args[0];
18
+ const target = args[1];
19
+
20
+ switch (command) {
21
+ case 'init':
22
+ initProject();
23
+ break;
24
+ case 'plan':
25
+ if (!target) {
26
+ console.error('Error: Please specify a feature name. Example: npx plankit plan my-feature');
27
+ process.exit(1);
28
+ }
29
+ planFeature(target);
30
+ break;
31
+ case 'status':
32
+ showStatus();
33
+ break;
34
+ case 'archive':
35
+ if (!target) {
36
+ console.error('Error: Please specify a feature name. Example: npx plankit archive my-feature');
37
+ process.exit(1);
38
+ }
39
+ archiveFeature(target);
40
+ break;
41
+ case 'help':
42
+ case '--help':
43
+ case '-h':
44
+ default:
45
+ showHelp();
46
+ break;
47
+ }
48
+ }
49
+
50
+ function ensureDir(dirPath) {
51
+ if (!fs.existsSync(dirPath)) {
52
+ fs.mkdirSync(dirPath, { recursive: true });
53
+ }
54
+ }
55
+
56
+ function writeFile(filePath, content) {
57
+ ensureDir(path.dirname(filePath));
58
+ fs.writeFileSync(filePath, content, 'utf8');
59
+ }
60
+
61
+ function initProject() {
62
+ console.log('🚀 Initializing PlanKit Command Suite in project...');
63
+
64
+ const cwd = process.cwd();
65
+
66
+ // 1. Artifacts directories & spec files
67
+ ensureDir(path.join(cwd, 'artifacts', 'current'));
68
+ ensureDir(path.join(cwd, 'artifacts', 'archived'));
69
+ writeFile(path.join(cwd, 'artifacts', 'PLANKIT.md'), PLANKIT_SPEC_TEMPLATE);
70
+ writeFile(path.join(cwd, 'artifacts', 'current', '.gitkeep'), '');
71
+ writeFile(path.join(cwd, 'artifacts', 'archived', '.gitkeep'), '');
72
+
73
+ // 2. Gemini / Antigravity instructions
74
+ writeFile(path.join(cwd, '.gemini', 'instructions.md'), GEMINI_INSTRUCTIONS_TEMPLATE);
75
+
76
+ // 3. Cursor rules
77
+ writeFile(path.join(cwd, '.cursorrules'), CURSORRULES_TEMPLATE);
78
+
79
+ // 4. AGENTS.md
80
+ writeFile(path.join(cwd, 'AGENTS.md'), AGENTS_MD_TEMPLATE);
81
+
82
+ // 5. OpenCode command markdown files
83
+ const opencodeDir = path.join(cwd, '.opencode', 'commands');
84
+ writeFile(path.join(opencodeDir, 'plankit-plan.md'), OPENCODE_COMMAND_PLAN);
85
+ writeFile(path.join(opencodeDir, 'plankit-clarify.md'), OPENCODE_COMMAND_CLARIFY);
86
+ writeFile(path.join(opencodeDir, 'plankit-implement.md'), OPENCODE_COMMAND_IMPLEMENT);
87
+ writeFile(path.join(opencodeDir, 'plankit-review.md'), OPENCODE_COMMAND_REVIEW);
88
+ writeFile(path.join(opencodeDir, 'plankit.md'), OPENCODE_COMMAND_MASTER);
89
+
90
+ // 6. Global Gemini Skills setup
91
+ try {
92
+ const userHome = os.homedir();
93
+ const globalSkillsDir = path.join(userHome, '.gemini', 'skills');
94
+
95
+ const skillsToCreate = [
96
+ { name: 'plankit', desc: 'PlanKit Command Suite master skill.' },
97
+ { name: 'plankit-plan', desc: 'Initialize feature under artifacts/current/<feature-name>/.' },
98
+ { name: 'plankit-clarify', desc: 'Analyze requirements and ask targeted clarifying questions.' },
99
+ { name: 'plankit-implement', desc: 'Execute Phase N reading spec and previous outputs.' },
100
+ { name: 'plankit-review', desc: 'Run test & build verification, validate DoD, and archive feature.' }
101
+ ];
102
+
103
+ for (const skill of skillsToCreate) {
104
+ const skillPath = path.join(globalSkillsDir, skill.name, 'SKILL.md');
105
+ const skillContent = `---\nname: ${skill.name}\ndescription: ${skill.desc}\n---\n\n# ${skill.name}\n${skill.desc}\n`;
106
+ writeFile(skillPath, skillContent);
107
+ }
108
+ console.log(' ✓ Installed global Gemini skills in ~/.gemini/skills/');
109
+ } catch (e) {
110
+ // Ignore global home dir write errors if restricted
111
+ }
112
+
113
+ console.log('\n✅ PlanKit successfully initialized!');
114
+ console.log('\nCreated / Updated configuration files:');
115
+ console.log(' - artifacts/PLANKIT.md');
116
+ console.log(' - .gemini/instructions.md');
117
+ console.log(' - .cursorrules');
118
+ console.log(' - AGENTS.md');
119
+ console.log(' - .opencode/commands/*.md');
120
+ console.log('\nNext steps:');
121
+ console.log(' Run "npx plankit plan <feature-name>" to start a new feature.');
122
+ }
123
+
124
+ function planFeature(featureName) {
125
+ const cwd = process.cwd();
126
+ const featureDir = path.join(cwd, 'artifacts', 'current', featureName);
127
+
128
+ if (fs.existsSync(featureDir)) {
129
+ console.log(`⚠️ Feature folder "${featureName}" already exists at artifacts/current/${featureName}`);
130
+ return;
131
+ }
132
+
133
+ console.log(`🚀 Creating new feature workspace for "${featureName}"...`);
134
+
135
+ ensureDir(path.join(featureDir, 'phases'));
136
+ ensureDir(path.join(featureDir, 'outputs'));
137
+
138
+ const readmeContent = `# Feature: ${featureName}
139
+
140
+ ## Overview
141
+ Detailed description of the feature goal and scope.
142
+
143
+ ## Phase Breakdown & Progress Status
144
+
145
+ - [ ] Phase 1: Foundation & Setup — ([Spec](phases/phase-1-foundation.md))
146
+ - [ ] Phase 2: Core Implementation
147
+ - [ ] Phase 3: Testing & Verification
148
+
149
+ ## Phase Execution Matrix
150
+
151
+ | Phase # | Phase Title | Spec Path | Output Path | Status |
152
+ |---|---|---|---|---|
153
+ | Phase 1 | Foundation & Setup | \`phases/phase-1-foundation.md\` | \`outputs/phase-1-output.md\` | **PENDING** |
154
+ `;
155
+
156
+ const phase1Spec = `# Phase 1: Foundation & Setup
157
+
158
+ ## 1. Objective
159
+ Establish base structure and foundational dependencies for ${featureName}.
160
+
161
+ ## 2. Tasks
162
+ - [ ] Initial setup
163
+ - [ ] Basic implementation
164
+ `;
165
+
166
+ writeFile(path.join(featureDir, 'README.md'), readmeContent);
167
+ writeFile(path.join(featureDir, 'phases', 'phase-1-foundation.md'), phase1Spec);
168
+ writeFile(path.join(featureDir, 'outputs', '.gitkeep'), '');
169
+
170
+ console.log(`\n✅ Feature "${featureName}" initialized successfully!`);
171
+ console.log(` - Spec: artifacts/current/${featureName}/phases/phase-1-foundation.md`);
172
+ console.log(` - Overview: artifacts/current/${featureName}/README.md`);
173
+ }
174
+
175
+ function showStatus() {
176
+ const cwd = process.cwd();
177
+ const currentDir = path.join(cwd, 'artifacts', 'current');
178
+ const archivedDir = path.join(cwd, 'artifacts', 'archived');
179
+
180
+ console.log('📊 PlanKit Feature Status Summary:\n');
181
+
182
+ if (fs.existsSync(currentDir)) {
183
+ const currentFeatures = fs.readdirSync(currentDir).filter(f => !f.startsWith('.'));
184
+ console.log('📌 ACTIVE FEATURES (artifacts/current/):');
185
+ if (currentFeatures.length === 0) {
186
+ console.log(' (none)');
187
+ } else {
188
+ currentFeatures.forEach(f => console.log(` - 🟡 ${f}`));
189
+ }
190
+ }
191
+
192
+ console.log('');
193
+
194
+ if (fs.existsSync(archivedDir)) {
195
+ const archivedFeatures = fs.readdirSync(archivedDir).filter(f => !f.startsWith('.'));
196
+ console.log('📦 ARCHIVED FEATURES (artifacts/archived/):');
197
+ if (archivedFeatures.length === 0) {
198
+ console.log(' (none)');
199
+ } else {
200
+ archivedFeatures.forEach(f => console.log(` - 🟢 ${f}`));
201
+ }
202
+ }
203
+ }
204
+
205
+ function archiveFeature(featureName) {
206
+ const cwd = process.cwd();
207
+ const sourceDir = path.join(cwd, 'artifacts', 'current', featureName);
208
+ const targetDir = path.join(cwd, 'artifacts', 'archived', featureName);
209
+
210
+ if (!fs.existsSync(sourceDir)) {
211
+ console.error(`Error: Active feature "${featureName}" not found in artifacts/current/`);
212
+ process.exit(1);
213
+ }
214
+
215
+ ensureDir(path.dirname(targetDir));
216
+ fs.renameSync(sourceDir, targetDir);
217
+
218
+ console.log(`✅ Archived feature "${featureName}" -> artifacts/archived/${featureName}`);
219
+ }
220
+
221
+ function showHelp() {
222
+ console.log(`
223
+ PlanKit CLI — Command Suite for AI Coding Assistants
224
+
225
+ Usage:
226
+ npx plankit <command> [options]
227
+
228
+ Commands:
229
+ init Initialize PlanKit rules & commands in the current project
230
+ plan <feature-name> Create a new feature workspace under artifacts/current/<feature-name>/
231
+ status Show status of all active and archived features
232
+ archive <feature-name> Move a completed feature to artifacts/archived/<feature-name>/
233
+ help Show this help message
234
+ `);
235
+ }
@@ -0,0 +1,149 @@
1
+ export const AGENTS_MD_TEMPLATE = `# AGENTS.md — PlanKit Command Suite for AI Agents
2
+
3
+ All AI coding assistants (Codex, Claude Code, OpenCode, Antigravity, Cursor) interacting with this codebase must follow the **PlanKit Command Suite**:
4
+
5
+ ## Commands
6
+
7
+ 1. \`plankit.plan\` (or \`/plankit-plan\`): Initialize feature under \`artifacts/current/<feature-name>/\`, create \`README.md\` progress matrix, and write \`phases/phase-N-*.md\` specs.
8
+ 2. \`plankit.clarify\` (or \`/plankit-clarify\`): Analyze requirements and ask targeted clarifying questions before executing code edits.
9
+ 3. \`plankit.implement\` (or \`/plankit-implement\`): Execute Phase N by reading \`phases/phase-N.md\` **AND all previous outputs** (\`outputs/phase-1..N-1-output.md\`), writing \`outputs/phase-N-output.md\`, and updating \`README.md\`.
10
+ 4. \`plankit.review\` (or \`/plankit-review\`): Run test & build verification, validate DoD, and move feature folder to \`artifacts/archived/<feature-name>\`.
11
+
12
+ Canonical Specification: \`artifacts/PLANKIT.md\`
13
+ `;
14
+
15
+ export const CURSORRULES_TEMPLATE = `# Cursor AI Rules — PlanKit Command Suite
16
+
17
+ You MUST follow the PlanKit multi-phase feature development standard defined in \`artifacts/PLANKIT.md\`.
18
+
19
+ ## Recognized PlanKit Commands
20
+
21
+ - **plankit.plan**: Create \`artifacts/current/<feature-name>/\`, master \`README.md\`, and \`phases/phase-N-*.md\` specs.
22
+ - **plankit.clarify**: Inspect codebase & specs, then ask structured clarifying questions before editing code.
23
+ - **plankit.implement**: Read target spec AND \`outputs/phase-1..N-1-output.md\`, execute changes, write \`outputs/phase-N-output.md\`, and mark Phase N \`[x]\` in \`README.md\`.
24
+ - **plankit.review**: Run \`npm run test\` & \`npm run build\`, validate DoD checklist, and move folder to \`artifacts/archived/<feature-name>\`.
25
+ `;
26
+
27
+ export const GEMINI_INSTRUCTIONS_TEMPLATE = `# Antigravity Workspace Rules — PlanKit Integration
28
+
29
+ Whenever working in this workspace, strictly adhere to the **PlanKit Command Suite** defined in \`artifacts/PLANKIT.md\`.
30
+
31
+ ## Recognized PlanKit Commands
32
+
33
+ ### 1. \`plankit.plan\` [feature-description]
34
+ - Create \`artifacts/current/<feature-name>/\`.
35
+ - Create \`README.md\` with overview, progress table, and \`[ ]\` checkboxes.
36
+ - Create phase specs in \`phases/phase-N-*.md\`.
37
+ - Present Phase 1 implementation plan.
38
+
39
+ ### 2. \`plankit.clarify\`
40
+ - Read \`artifacts/current/<feature-name>/README.md\` and target spec in \`phases/\`.
41
+ - Inspect codebase and present structured clarifying questions to user before modifying code.
42
+
43
+ ### 3. \`plankit.implement\` [Phase N]
44
+ - Read \`phases/phase-N-*.md\` **AND all previous outputs** (\`outputs/phase-1..N-1-output.md\`).
45
+ - Execute changes, run tests, write \`outputs/phase-N-output.md\`, and update \`README.md\` (\`[x]\`).
46
+
47
+ ### 4. \`plankit.review\`
48
+ - Run \`npm run test\` and \`npm run build\`.
49
+ - Validate DoD checklist.
50
+ - Move completed feature folder from \`artifacts/current/<feature-name>\` to \`artifacts/archived/<feature-name>\`.
51
+ `;
52
+
53
+ export const OPENCODE_COMMAND_PLAN = `---
54
+ description: Initialize a new feature under artifacts/current/<feature-name>/, create README.md progress matrix, and write phases/phase-N-*.md specs.
55
+ ---
56
+
57
+ Initialize a new feature in the workspace according to PlanKit SOP.
58
+
59
+ Requirements: $ARG
60
+
61
+ Steps:
62
+ 1. Create directory \`artifacts/current/$ARG/\` (or determine feature name from prompt).
63
+ 2. Create \`artifacts/current/<feature-name>/README.md\` containing feature overview, architecture summary, DoD checklist, and progress status matrix.
64
+ 3. Write phase specification files under \`artifacts/current/<feature-name>/phases/phase-N-<step-name>.md\`.
65
+ 4. Generate the detailed Phase 1 implementation plan artifact and request user approval.
66
+ `;
67
+
68
+ export const OPENCODE_COMMAND_CLARIFY = `---
69
+ description: Analyze requirements and codebase to ask targeted clarifying questions before executing code edits.
70
+ ---
71
+
72
+ Analyze requirements and clarify design decisions according to PlanKit SOP.
73
+
74
+ 1. Read \`artifacts/current/<feature-name>/README.md\` and target spec in \`phases/\`.
75
+ 2. Inspect relevant codebase files to identify existing patterns, schemas, or potential breaking changes.
76
+ 3. Formulate and present structured clarifying questions for the user regarding design choices, API contracts, or edge cases.
77
+ 4. Do NOT make code changes until the user responds.
78
+ `;
79
+
80
+ export const OPENCODE_COMMAND_IMPLEMENT = `---
81
+ description: Execute Phase N by reading phases/phase-N.md AND all previous outputs, writing outputs/phase-N-output.md, and updating README.md.
82
+ ---
83
+
84
+ Execute a feature phase according to PlanKit SOP.
85
+
86
+ Phase to implement: $ARG
87
+
88
+ 1. Read target phase spec: \`artifacts/current/<feature-name>/phases/phase-N-*.md\`.
89
+ 2. **Mandatory Context Load**: Read **ALL** previous output reports: \`outputs/phase-1-output.md\` through \`outputs/phase-(N-1)-output.md\`.
90
+ 3. Execute code and configuration modifications.
91
+ 4. Run automated tests or build verification commands.
92
+ 5. Write execution report to \`artifacts/current/<feature-name>/outputs/phase-N-output.md\`.
93
+ 6. Update \`artifacts/current/<feature-name>/README.md\`: mark Phase N as \`[x]\` and update status matrix.
94
+ `;
95
+
96
+ export const OPENCODE_COMMAND_REVIEW = `---
97
+ description: Run test & build verification, validate DoD, and move feature folder to artifacts/archived/<feature-name>.
98
+ ---
99
+
100
+ Verify a completed feature and archive it according to PlanKit SOP.
101
+
102
+ 1. Run full test suite (\`npm run test\`) and production build (\`npm run build\`).
103
+ 2. Validate all Definition of Done checklist items in \`artifacts/current/<feature-name>/README.md\`.
104
+ 3. Update \`README.md\` header title to \`# Feature: <Feature Name> [ARCHIVED]\`.
105
+ 4. Move \`artifacts/current/<feature-name>\` directory to \`artifacts/archived/<feature-name>\`.
106
+ 5. Present final completion summary report to user.
107
+ `;
108
+
109
+ export const OPENCODE_COMMAND_MASTER = `---
110
+ description: PlanKit Command Suite master command. Evaluate sub-action (plan, clarify, implement, review).
111
+ ---
112
+
113
+ PlanKit Command Suite master command.
114
+
115
+ Sub-action / Arguments: $ARG
116
+
117
+ Evaluate the sub-action:
118
+ - \`plan\`: Initialize feature under \`artifacts/current/<feature-name>/\`, create \`README.md\` matrix, and write \`phases/phase-N-*.md\` specs.
119
+ - \`clarify\`: Inspect codebase and specs, then ask structured clarifying questions before implementing code.
120
+ - \`implement\`: Read target spec AND all previous outputs (\`outputs/phase-1..N-1-output.md\`), execute changes, write \`outputs/phase-N-output.md\`, and update \`README.md\`.
121
+ - \`review\`: Run \`npm run test\` & \`npm run build\`, validate DoD checklist, and archive completed feature to \`artifacts/archived/<feature-name>\`.
122
+ `;
123
+
124
+ export const PLANKIT_SPEC_TEMPLATE = `# PlanKit Command Suite Specification
125
+
126
+ > [!IMPORTANT]
127
+ > **PlanKit Standard**: PlanKit is a standardized, tool-agnostic command framework for AI coding assistants. It organizes multi-phase feature development into distinct, predictable steps with context-aware execution and automated progress tracking.
128
+
129
+ ---
130
+
131
+ ## The 4 Core Commands
132
+
133
+ ### 1. \`plankit.plan\` [feature-name] [requirements]
134
+ - **Purpose**: Initializes a new feature task.
135
+ - **Actions**:
136
+ 1. Creates feature directory: \`artifacts/current/<feature-name>/\`.
137
+ 2. Creates master overview & status tracking table in \`artifacts/current/<feature-name>/README.md\`.
138
+ 3. Creates phase specification files: \`artifacts/current/<feature-name>/phases/phase-1-<name>.md\`, \`phase-2-<name>.md\`, etc.
139
+ 4. Generates initial Phase 1 implementation plan artifact and requests user approval.
140
+
141
+ ### 2. \`plankit.clarify\`
142
+ - **Purpose**: Conducts a structured design alignment and requirements interview.
143
+
144
+ ### 3. \`plankit.implement\` [Phase N]
145
+ - **Purpose**: Executes a single phase with context continuity. Reads \`phases/phase-N.md\` AND all previous outputs (\`outputs/phase-1..N-1-output.md\`).
146
+
147
+ ### 4. \`plankit.review\`
148
+ - **Purpose**: Verifies Definition of Done (DoD) and archives completed features to \`artifacts/archived/\`.
149
+ `;