@patricksardinha/agentkit-cli 0.2.0 → 0.3.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.
@@ -0,0 +1,43 @@
1
+ # Skills — Agent 3 · Generators & Templates
2
+
3
+ > This file is read by Agent 3 before starting its work.
4
+
5
+ ## Template function signature
6
+
7
+ Every template file must export exactly these two functions:
8
+
9
+ ```typescript
10
+ export function claudeMd(stack: StackInfo): string
11
+ export function workflow(stack: StackInfo): string
12
+ ```
13
+
14
+ The `workflow()` function returns a markdown string. The workflowGenerator
15
+ is responsible for parsing that string into an `Agent[]` array.
16
+
17
+ ## Agent type
18
+
19
+ ```typescript
20
+ export interface Agent {
21
+ number: number // 1, 2, 3…
22
+ slug: string // 'infra', 'auth', 'features'…
23
+ name: string // 'Infra & Setup', 'Auth & Supabase'…
24
+ scope: string // one-line description
25
+ outputs: string[]
26
+ criterion: string // the runnable bash command
27
+ }
28
+ ```
29
+
30
+ ## Blueprint parsing
31
+
32
+ When `blueprintContent` is provided, parse `## Feature` sections
33
+ using simple line splitting — no external markdown parser needed.
34
+ Extract bullet points under each `##` heading and use them to name
35
+ and scope the generated agents.
36
+
37
+ ## playbookGenerator rules
38
+
39
+ The PLAYBOOK.md must always start with the one-instruction block:
40
+ > "Read PLAYBOOK.md and execute the procedure."
41
+
42
+ The retry limit is always 3. The escalation section is always present.
43
+ Do not make these values configurable — consistency is the point.
@@ -0,0 +1,37 @@
1
+ # Skills — Agent 4 · Commands CLI
2
+
3
+ > This file is read by Agent 4 before starting its work.
4
+
5
+ ## Commander.js setup
6
+
7
+ The CLI binary is `agentkit`. The three subcommands are:
8
+ - `init [options]` with `--blueprint <path>`
9
+ - `add [options]` with `--feature <description>`
10
+ - `status`
11
+
12
+ ## init command behavior
13
+
14
+ 1. Run gitDetector — warn but don't block if not a git repo
15
+ 2. Run stackDetector on process.cwd()
16
+ 3. If --blueprint provided: read file, warn if path doesn't exist
17
+ 4. Call claudeMdGenerator(stack, blueprintContent?)
18
+ 5. Call workflowGenerator(stack, blueprintContent?) → { markdown, agents }
19
+ 6. Call playbookGenerator(agents, projectName)
20
+ 7. Call skillsGenerator(agents)
21
+ 8. Write all files — never overwrite existing files without --force flag
22
+
23
+ ## add command behavior
24
+
25
+ 1. Check AGENT_WORKFLOW.md exists — error if not (run init first)
26
+ 2. Parse existing agents to find the last number
27
+ 3. Generate new agent block from --feature description
28
+ 4. Append to AGENT_WORKFLOW.md
29
+ 5. Create agents/agent-{N+1}-{slug}/skills.md
30
+ 6. Regenerate PLAYBOOK.md entirely (not append — full regeneration)
31
+
32
+ ## Output rules
33
+
34
+ - Use logger.ts for all output — never console.log directly
35
+ - Use ora spinner during file generation
36
+ - Use chalk.green for success, chalk.yellow for warnings, chalk.red for errors
37
+ - Always print a summary of generated files at the end of init
package/dist/cli.cjs CHANGED
@@ -684,67 +684,163 @@ ${agentBlocks.join("\n\n")}
684
684
  }
685
685
 
686
686
  // src/generators/playbookGenerator.ts
687
- function generatePlaybook({ agents, projectName }) {
687
+ function generatePlaybook({ agents, projectName, hasBlueprint }) {
688
688
  const agentBlocks = agents.map((a) => agentBlock(a)).join("\n---\n\n");
689
+ const phase0 = hasBlueprint ? `## Phase 0 \u2014 Agent Decomposition (run this first)
690
+
691
+ > A \`PROJECT_BLUEPRINT.md\` was provided.
692
+ > Claude Code reads it and decomposes the project into specialized agents
693
+ > before writing a single line of code.
694
+
695
+ **Read these files in order:**
696
+ 1. \`CLAUDE.md\`
697
+ 2. \`PROJECT_BLUEPRINT.md\`
698
+
699
+ **Then decompose the project into agents** following these rules:
700
+
701
+ - One agent = one coherent technical layer (never mix two layers)
702
+ - Each agent must have a runnable success criterion (\`npm test\`, \`cargo build\`\u2026)
703
+ - Agents must be ordered by dependency (no feature without infra first)
704
+ - Maximum 6 agents \u2014 if you have more, group related ones
705
+ - Always respect this order:
706
+ 1. Infra & Configuration
707
+ 2. Data layer (DB schema, models, services)
708
+ 3. External integrations (auth, APIs, local services like Ollama)
709
+ 4. UI & pages
710
+ 5. Advanced features (RAG, export, realtime\u2026)
711
+ 6. Build & release (CI/CD, packaging, installers)
712
+
713
+ **Write the result directly into \`AGENT_WORKFLOW.md\`** \u2014 replace its current
714
+ content with your decomposition.
715
+
716
+ **Then ask for human validation:**
717
+ > "I have decomposed the project into N agents: [list them].
718
+ > Should I proceed with execution?"
719
+
720
+ Wait for confirmation before moving to Phase 1.
721
+
722
+ ---
723
+
724
+ ` : `## Phase 0 \u2014 Project Discovery (run this first)
725
+
726
+ > No \`PROJECT_BLUEPRINT.md\` was provided.
727
+ > Before writing any code, Claude Code asks the user what they want to build,
728
+ > then decomposes the project into agents \u2014 exactly as if a blueprint had been provided.
729
+
730
+ **Ask the user these questions and wait for their answers:**
731
+
732
+ 1. What is this project? (one sentence describing the goal)
733
+ 2. What are the main features you want to build? (list them)
734
+ 3. Are there any tech constraints or architecture preferences?
735
+ (e.g. offline-only, specific DB, no auth, specific framework)
736
+
737
+ **Once you have the answers, decompose the project into agents**
738
+ following these rules:
739
+
740
+ - One agent = one coherent technical layer (never mix two layers)
741
+ - Each agent must have a runnable success criterion (\`npm test\`, \`cargo build\`\u2026)
742
+ - Agents must be ordered by dependency (no feature without infra first)
743
+ - Maximum 6 agents \u2014 if you have more, group related ones
744
+ - Always respect this order:
745
+ 1. Infra & Configuration
746
+ 2. Data layer (DB schema, models, services)
747
+ 3. External integrations (auth, APIs, local services like Ollama)
748
+ 4. UI & pages
749
+ 5. Advanced features (RAG, export, realtime\u2026)
750
+ 6. Build & release (CI/CD, packaging, installers)
751
+
752
+ **Write the result directly into \`AGENT_WORKFLOW.md\`** \u2014 replace its current
753
+ content with your decomposition.
754
+
755
+ **Then ask for human validation:**
756
+ > "I have decomposed the project into N agents: [list them].
757
+ > Should I proceed with execution?"
758
+
759
+ Wait for confirmation before moving to Phase 1.
760
+
761
+ ---
762
+
763
+ `;
689
764
  return `# PLAYBOOK.md \u2014 ${projectName}
690
765
 
691
- > Donne cette instruction \xE0 Claude Code : 'Lis PLAYBOOK.md et ex\xE9cute la proc\xE9dure.'
766
+ > **One instruction to give Claude Code:**
767
+ > "Read PLAYBOOK.md and execute the procedure."
768
+ >
769
+ > Claude Code handles the rest autonomously \u2014 project discovery or blueprint reading,
770
+ > agent decomposition, execution, success validation, retries, and human escalation.
771
+ > No API key required. No additional cost beyond your LLM subscription.
692
772
 
693
- ## R\xE8gles d'ex\xE9cution globales
773
+ ---
694
774
 
695
- Avant chaque agent :
696
- 1. Lire \`CLAUDE.md\`
697
- 2. Lire \`agents/agent-{N}-{slug}/skills.md\` (le fichier de l'agent courant)
775
+ ## Global Execution Rules
698
776
 
699
- Apr\xE8s chaque agent :
700
- - Ex\xE9cuter le crit\xE8re de succ\xE8s
701
- - Si succ\xE8s \u2192 annoncer "\u2705 Agent N termin\xE9" et passer au suivant
702
- - Si \xE9chec \u2192 analyser la cause racine, corriger, r\xE9ex\xE9cuter (max 3 tentatives)
703
- - Apr\xE8s 3 \xE9checs cons\xE9cutifs \u2192 pause et demander validation humaine
704
- - **Ne jamais passer \xE0 l'agent suivant sans crit\xE8re valid\xE9**
777
+ Before each agent:
778
+ 1. Read \`CLAUDE.md\`
779
+ 2. Read \`agents/agent-{N}-{slug}/skills.md\` (current agent's file)
780
+ 3. Read the agent's section in \`AGENT_WORKFLOW.md\`
705
781
 
706
- ## Agents
782
+ After each agent:
783
+ - Run the success criterion command
784
+ - \u2705 Passes \u2192 announce "\u2705 Agent N complete" and move to the next
785
+ - \u274C Fails \u2192 analyze the root cause, fix, rerun (max 3 attempts)
786
+ - After 3 consecutive failures \u2192 stop and ask for human validation
787
+
788
+ **Never move to the next agent without a passing success criterion.**
789
+ **Stay strictly within your current agent's defined scope.**
790
+
791
+ ---
792
+
793
+ ${phase0}## Phase 1 \u2014 Execution
707
794
 
708
795
  ${agentBlocks}
709
796
 
710
- ## It\xE9rations futures
797
+ ---
798
+
799
+ ## Future Iterations
711
800
 
712
- Lorsqu'un nouvel agent est ajout\xE9 via \`agentkit add --feature <description>\` :
713
- 1. Un nouveau bloc agent est ajout\xE9 \xE0 la fin de \`AGENT_WORKFLOW.md\`
714
- 2. Le dossier \`agents/agent-{N}-{slug}/\` est cr\xE9\xE9 avec \`skills.md\` et \`context.md\`
715
- 3. Ce \`PLAYBOOK.md\` est r\xE9g\xE9n\xE9r\xE9 automatiquement pour inclure le nouvel agent
716
- 4. L'ex\xE9cution reprend \xE0 ce nouvel agent uniquement \u2014 les agents pr\xE9c\xE9dents ne sont pas r\xE9ex\xE9cut\xE9s
801
+ When a new agent is added via \`agentkit add --feature <description>\`:
802
+ 1. A new agent block is appended to \`AGENT_WORKFLOW.md\`
803
+ 2. The folder \`agents/agent-{N}-{slug}/\` is created with \`skills.md\`
804
+ 3. This \`PLAYBOOK.md\` is regenerated to include the new agent
805
+ 4. Execution resumes at the new agent only \u2014 completed agents are not rerun
717
806
 
718
- ## Validation humaine requise
807
+ When you receive the instruction to continue after an iteration:
808
+ > "Read PLAYBOOK.md and execute only the agents that haven't been completed yet."
719
809
 
720
- Les cas suivants n\xE9cessitent une pause et une confirmation humaine avant de continuer :
721
- - **3 \xE9checs cons\xE9cutifs** sur le crit\xE8re de succ\xE8s d'un agent
722
- - **D\xE9pendance externe manquante** : cl\xE9 API, variable d'environnement non d\xE9finie, service tiers inaccessible
723
- - **Conflit** entre le blueprint fourni (\`--blueprint\`) et la stack d\xE9tect\xE9e automatiquement
810
+ ---
811
+
812
+ ## Human Validation Required
813
+
814
+ Stop and wait for confirmation in these situations:
815
+ - **3 consecutive failures** on the same success criterion
816
+ - **Missing external dependency**: API key, env variable, unavailable service
817
+ - **Conflict** between the detected stack and the user's stated constraints
818
+ - **Destructive operation**: overwriting files not listed in deliverables
819
+ - **End of Phase 0**: agent decomposition must be validated before execution
724
820
  `;
725
821
  }
726
822
  function agentBlock(agent) {
727
823
  const skillsPath = `agents/agent-${agent.number}-${agent.slug}/skills.md`;
728
- const outputLines = agent.outputs.length > 0 ? agent.outputs.map((o) => `- ${o}`).join("\n") : "- (voir skills.md pour le d\xE9tail)";
729
- return `### ${agent.fullName}
824
+ const outputLines = agent.outputs.length > 0 ? agent.outputs.map((o) => `- ${o}`).join("\n") : "- (see skills.md for details)";
825
+ return `### Agent ${agent.number} \xB7 ${agent.name}
730
826
 
731
- **P\xE9rim\xE8tre** : ${agent.scope}
827
+ **Scope**: ${agent.scope}
732
828
 
733
- **Skills** : \`${skillsPath}\`
829
+ **Skills**: \`${skillsPath}\`
734
830
 
735
- **Fichiers produits** :
831
+ **Deliverables**:
736
832
  ${outputLines}
737
833
 
738
- **Crit\xE8re de succ\xE8s** :
834
+ **Success criterion**:
739
835
  \`\`\`bash
740
836
  ${agent.criterion || "npm run build && npm test"}
741
837
  \`\`\`
742
838
 
743
- **En cas d'\xE9chec** :
744
- 1. Analyser le message d'erreur complet
745
- 2. Corriger la cause racine (pas les sympt\xF4mes)
746
- 3. R\xE9ex\xE9cuter le crit\xE8re (max 3 tentatives)
747
- 4. Apr\xE8s 3 \xE9checs \u2192 demander validation humaine
839
+ **On failure**:
840
+ 1. Read the full error output
841
+ 2. Fix the root cause \u2014 not the symptoms
842
+ 3. Rerun the success criterion (max 3 attempts)
843
+ 4. After 3 failures \u2192 ask for human validation
748
844
  `;
749
845
  }
750
846
 
@@ -899,7 +995,7 @@ function registerInit(program2) {
899
995
  const claudeMdContent = generateClaudeMd(stack, blueprintContent);
900
996
  const workflowContent = generateWorkflow(stack, blueprintContent);
901
997
  const agents = extractAgentsFromWorkflow(workflowContent);
902
- const playbookContent = generatePlaybook({ agents, projectName });
998
+ const playbookContent = generatePlaybook({ agents, projectName, hasBlueprint: !!blueprintContent });
903
999
  await (0, import_promises4.writeFile)(claudeMdPath, claudeMdContent, "utf-8");
904
1000
  await (0, import_promises4.writeFile)(workflowPath, workflowContent, "utf-8");
905
1001
  await (0, import_promises4.writeFile)(playbookPath, playbookContent, "utf-8");
@@ -927,7 +1023,7 @@ async function addFeatureToProject(description, projectDir) {
927
1023
  try {
928
1024
  workflowContent = await (0, import_promises5.readFile)(workflowPath, "utf-8");
929
1025
  } catch {
930
- throw new Error(`AGENT_WORKFLOW.md introuvable dans ${projectDir} \u2014 lancez agentkit init`);
1026
+ throw new Error(`AGENT_WORKFLOW.md not found in ${projectDir} \u2014 run agentkit init first`);
931
1027
  }
932
1028
  const existingAgents = extractAgentsFromWorkflow(workflowContent);
933
1029
  const nextNumber = existingAgents.length + 1;
@@ -961,7 +1057,11 @@ Crit\xE8re : npm run build && npm test
961
1057
  } catch {
962
1058
  }
963
1059
  const allAgents = [...existingAgents, newAgent];
964
- const playbookContent = generatePlaybook({ agents: allAgents, projectName });
1060
+ const playbookContent = generatePlaybook({
1061
+ agents: allAgents,
1062
+ projectName,
1063
+ hasBlueprint: false
1064
+ });
965
1065
  await (0, import_promises5.writeFile)(playbookPath, playbookContent, "utf-8");
966
1066
  return {
967
1067
  agent: newAgent,
@@ -969,13 +1069,13 @@ Crit\xE8re : npm run build && npm test
969
1069
  };
970
1070
  }
971
1071
  function registerAdd(program2) {
972
- const addCmd = program2.command("add").description("Ajoute des ressources au projet agentkit").option("--feature <description>", "Ajoute un agent depuis une description de feature et r\xE9g\xE9n\xE8re PLAYBOOK.md").action(async (options) => {
1072
+ const addCmd = program2.command("add").description("Add resources to the agentkit project").option("--feature <description>", "Add an agent from a feature description and regenerate PLAYBOOK.md").action(async (options) => {
973
1073
  if (options.feature) {
974
1074
  try {
975
1075
  const result = await addFeatureToProject(options.feature, process.cwd());
976
- logger.success(`Agent ajout\xE9 : ${result.agent.fullName}`);
977
- logger.success(`Dossier cr\xE9\xE9 : agents/agent-${result.agent.number}-${result.agent.slug}/`);
978
- logger.success("PLAYBOOK.md : r\xE9g\xE9n\xE9r\xE9");
1076
+ logger.success(`Agent added : ${result.agent.fullName}`);
1077
+ logger.success(`Folder created : agents/agent-${result.agent.number}-${result.agent.slug}/`);
1078
+ logger.success("PLAYBOOK.md : regenerated");
979
1079
  } catch (err) {
980
1080
  logger.error(err instanceof Error ? err.message : String(err));
981
1081
  process.exit(1);
@@ -984,14 +1084,14 @@ function registerAdd(program2) {
984
1084
  addCmd.help();
985
1085
  }
986
1086
  });
987
- addCmd.command("agent").description("Ajoute un nouvel agent dans AGENT_WORKFLOW.md (interactif)").action(async () => {
1087
+ addCmd.command("agent").description("Add a new agent to AGENT_WORKFLOW.md (interactive)").action(async () => {
988
1088
  const cwd = process.cwd();
989
1089
  const workflowPath = (0, import_node_path6.join)(cwd, "AGENT_WORKFLOW.md");
990
1090
  let existing = "";
991
1091
  try {
992
1092
  existing = await (0, import_promises5.readFile)(workflowPath, "utf-8");
993
1093
  } catch {
994
- logger.error("AGENT_WORKFLOW.md introuvable \u2014 lancez d'abord : agentkit init");
1094
+ logger.error("AGENT_WORKFLOW.md not found \u2014 run agentkit init first");
995
1095
  process.exit(1);
996
1096
  }
997
1097
  const agentCount = (existing.match(/^### Agent \d+/gm) ?? []).length;
@@ -1000,23 +1100,23 @@ function registerAdd(program2) {
1000
1100
  {
1001
1101
  type: "input",
1002
1102
  name: "name",
1003
- message: `Nom de l'agent (ex: "Agent ${nextNumber} \xB7 Feature X") :`,
1103
+ message: `Agent name (e.g. "Agent ${nextNumber} \xB7 Feature X"):`,
1004
1104
  default: `Agent ${nextNumber}`
1005
1105
  },
1006
1106
  {
1007
1107
  type: "input",
1008
1108
  name: "scope",
1009
- message: "P\xE9rim\xE8tre (une phrase) :"
1109
+ message: "Scope (one sentence):"
1010
1110
  },
1011
1111
  {
1012
1112
  type: "input",
1013
1113
  name: "outputs",
1014
- message: "Fichiers produits (s\xE9par\xE9s par des virgules) :"
1114
+ message: "Deliverables (comma-separated):"
1015
1115
  },
1016
1116
  {
1017
1117
  type: "input",
1018
1118
  name: "criterion",
1019
- message: "Crit\xE8re de succ\xE8s :"
1119
+ message: "Success criterion:"
1020
1120
  }
1021
1121
  ]);
1022
1122
  const outputLines = answers.outputs.split(",").map((o) => ` - ${o.trim()}`).join("\n");
@@ -1028,7 +1128,7 @@ ${outputLines}
1028
1128
  Crit\xE8re : ${answers.criterion}
1029
1129
  `;
1030
1130
  await (0, import_promises5.writeFile)(workflowPath, existing + agentSection, "utf-8");
1031
- logger.success(`Agent "${answers.name}" ajout\xE9 dans AGENT_WORKFLOW.md`);
1131
+ logger.success(`Agent "${answers.name}" added to AGENT_WORKFLOW.md`);
1032
1132
  });
1033
1133
  }
1034
1134