@valentia-ai-skills/framework 2.0.6 → 2.0.7

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 (3) hide show
  1. package/README.md +7 -7
  2. package/bin/cli.js +125 -71
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -70,9 +70,9 @@ npx ai-skills upload-legacy-scan --path ./my-project-intelligence/
70
70
  npx ai-skills upload-legacy-scan --path ./my-project-intelligence/ --dry-run # validate only
71
71
  npx ai-skills upload-legacy-scan --path ./my-project-intelligence/ --token <token>
72
72
 
73
- # Download a project's skills from the console install into your local AI tools
73
+ # Download a project recreates exact intelligence folder structure (modules/, diagrams/, reports)
74
74
  npx ai-skills legacy-projects add "My Project"
75
- npx ai-skills legacy-projects add "My Project" --path ./output-dir/ # also save raw files locally
75
+ npx ai-skills legacy-projects add "My Project" --path ~/projects/ # save to a specific directory
76
76
 
77
77
  # List all legacy projects for your team
78
78
  npx ai-skills legacy-projects list
@@ -288,8 +288,8 @@ The framework supports ingesting intelligence packages generated by legacy codeb
288
288
  1. **Scan** — A compatible scanner tool analyses an existing codebase and produces an intelligence folder
289
289
  2. **Upload** — `npx ai-skills upload-legacy-scan --path <folder>` ships the intelligence package to your team's Skills Console, creating or refreshing the project
290
290
  3. **Review** — Tech leads review auto-generated skills, reports, and diagrams in the Skills Console, approving or flagging each document
291
- 4. **Install** — Developers run `npx ai-skills legacy-projects add <project-name>` to download approved skills from the console and have them installed into their local AI tools automatically
292
- 5. **Code** — AI tools (Claude Code, Cursor, Copilot, Windsurf) now have full context about the legacy project's patterns
291
+ 4. **Download** — Developers run `npx ai-skills legacy-projects add <project-name>` to reconstruct the full intelligence package folder locally identical structure to the original scan output (`modules/`, `diagrams/`, report `.md` files, `manifest.json`)
292
+ 5. **Code** — AI tools (Claude Code, Cursor, Copilot, Windsurf) can now read the local package using the project's legacy-reading skills
293
293
  6. **Rescan** — Re-running `upload-legacy-scan` on the same project name replaces all documents with the latest scan output
294
294
 
295
295
  ### Intelligence Package Format
@@ -348,9 +348,9 @@ Approved skills are promoted into the team's standard toolkit and distributed on
348
348
  # Upload a scan package (add new project or replace existing)
349
349
  npx ai-skills upload-legacy-scan --path ./my-project-intelligence/
350
350
 
351
- # Download a project's skills and install them into your local AI tools
352
- npx ai-skills legacy-projects add "My Project"
353
- npx ai-skills legacy-projects add "My Project" --path ./output/ # also write raw files locally
351
+ # Download a project recreates the exact intelligence package folder structure locally
352
+ npx ai-skills legacy-projects add "Clinical Sanctuary"
353
+ npx ai-skills legacy-projects add "Clinical Sanctuary" --path ~/projects/ # save to specific dir
354
354
 
355
355
  # List all projects with status, module count, and completeness score
356
356
  npx ai-skills legacy-projects list
package/bin/cli.js CHANGED
@@ -1665,22 +1665,33 @@ async function cmdLegacyProjects() {
1665
1665
  console.log(`\n Console: ${c("dim", p.console_url)}\n`);
1666
1666
 
1667
1667
  } else if (subcommand === "add") {
1668
- // Download a legacy project's skills from the console and install them
1669
- // into the developer's local AI tools (Claude Code, Cursor, Copilot, Windsurf).
1668
+ // Download a legacy project from the console and reconstruct the complete
1669
+ // intelligence package folder structure the exact same layout produced
1670
+ // by the scanner so existing legacy-reading skills can work on it.
1671
+ //
1672
+ // Output:
1673
+ // <outputDir>/<project-slug>/
1674
+ // manifest.json
1675
+ // MASTER_SKILL.md (master skill, if present)
1676
+ // modules/<name>/SKILL.md (module skills)
1677
+ // diagrams/<name>.mmd
1678
+ // OVERVIEW.md / API_REGISTRY.md / RISK_REPORT.md … (reports/guides)
1679
+
1670
1680
  const projectName = args[0];
1671
1681
  if (!projectName) {
1672
- console.log(c("red", "Usage: npx ai-skills legacy-projects add <project-name> [--path <dir>]"));
1673
- console.log(c("dim", " Downloads the project's skills from the console and installs them into your AI tools.\n"));
1682
+ console.log(c("red", "Usage: npx ai-skills legacy-projects add <project-name> [--path <output-dir>]"));
1683
+ console.log(c("dim", " Downloads the project intelligence package and recreates the original folder structure.\n"));
1674
1684
  process.exit(1);
1675
1685
  }
1676
1686
 
1677
- // Optional --path flag to also save raw files to a local directory
1678
- let outputPath = null;
1687
+ // --path defaults to current working directory
1688
+ let outputBase = process.cwd();
1679
1689
  for (let i = 1; i < args.length; i++) {
1680
- if (args[i] === "--path" && args[i + 1]) outputPath = args[++i];
1690
+ if (args[i] === "--path" && args[i + 1]) outputBase = args[++i];
1681
1691
  }
1682
1692
 
1683
- console.log(c("blue", `\n━━━ Install Legacy Project: ${projectName} ━━━\n`));
1693
+ console.log(c("blue", `\n━━━ Download Legacy Project: ${projectName} ━━━\n`));
1694
+
1684
1695
  let result;
1685
1696
  try {
1686
1697
  result = await fetchJSONWithAuth(MANAGE_LEGACY_PROJECTS_URL, { action: "download", email, project_name: projectName }, null);
@@ -1693,80 +1704,123 @@ async function cmdLegacyProjects() {
1693
1704
  const documents = result.documents || [];
1694
1705
 
1695
1706
  if (documents.length === 0) {
1696
- console.log(c("yellow", "No documents found for this project.\n Check the project name or upload a scan first with:\n npx ai-skills upload-legacy-scan --path <dir>\n"));
1707
+ console.log(c("yellow", `No documents found for "${projectName}".\n Check the project name with: npx ai-skills legacy-projects list\n`));
1697
1708
  return;
1698
1709
  }
1699
1710
 
1700
- const skillDocs = documents.filter((d) => d.category === "skill");
1701
- const reportDocs = documents.filter((d) => d.category === "report" || d.category === "guide");
1711
+ const skillDocs = documents.filter((d) => d.category === "skill");
1712
+ const reportDocs = documents.filter((d) => d.category === "report");
1713
+ const guideDocs = documents.filter((d) => d.category === "guide");
1702
1714
  const diagramDocs = documents.filter((d) => d.category === "diagram");
1703
1715
 
1704
- console.log(` Project: ${c("bold", project.name)}`);
1705
- console.log(` Status: ${project.status} | ${project.completeness_score}% complete`);
1706
- console.log(` Skills: ${skillDocs.length} Reports: ${reportDocs.length} Diagrams: ${diagramDocs.length}\n`);
1707
-
1708
- // ── Install skill documents into local AI tools ──
1709
- if (skillDocs.length > 0) {
1710
- const tools = detectTools();
1711
- if (tools.length === 0) {
1712
- console.log(c("yellow", " ⚠ No AI tools detected — install Claude Code, Cursor, Copilot, or Windsurf first.\n"));
1713
- } else {
1714
- // Build skill objects in the format installSkillsForTool expects
1715
- const skills = skillDocs.map((doc) => ({
1716
- name: `legacy-${doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "")}`,
1717
- scope: "global", // global so filterSkillsForProject passes them through
1718
- content: doc.content,
1719
- }));
1720
-
1721
- console.log(` Installing into detected AI tools:\n`);
1722
- for (const toolKey of tools) {
1723
- const tool = TOOL_CONFIGS[toolKey];
1724
- const count = installSkillsForTool(toolKey, skills);
1725
- console.log(` ${c("green", "✓")} ${tool.name}: ${count} skill(s)`);
1726
- }
1727
- console.log("");
1728
- }
1729
- } else {
1730
- console.log(c("dim", " No skills in this project (reports/diagrams only).\n"));
1731
- }
1732
-
1733
- // ── Optionally save the full raw package to --path ──
1734
- if (outputPath) {
1735
- const resolved = path.resolve(outputPath);
1736
- mkdirp(resolved);
1737
-
1738
- if (skillDocs.length > 0) {
1739
- const modulesDir = path.join(resolved, "modules");
1740
- mkdirp(modulesDir);
1741
- for (const doc of skillDocs) {
1742
- const safeName = doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1743
- const docDir = path.join(modulesDir, safeName);
1744
- mkdirp(docDir);
1745
- fs.writeFileSync(path.join(docDir, "SKILL.md"), doc.content);
1746
- }
1716
+ console.log(` Project: ${c("bold", project.name)}`);
1717
+ console.log(` Status: ${project.status} | ${project.completeness_score}% complete`);
1718
+ console.log(` Skills: ${skillDocs.length} Reports: ${reportDocs.length} Guides: ${guideDocs.length} Diagrams: ${diagramDocs.length}\n`);
1719
+
1720
+ // ── Create project root folder ──
1721
+ const projectSlug = project.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1722
+ const projectDir = path.resolve(outputBase, `${projectSlug}-intelligence`);
1723
+ mkdirp(projectDir);
1724
+ console.log(` Saving to: ${c("bold", projectDir)}\n`);
1725
+
1726
+ // ── Skill documents ──
1727
+ const masterDoc = skillDocs.find((d) => d.document_type === "master");
1728
+ const moduleDocs = skillDocs.filter((d) => d.document_type !== "master").sort((a, b) => a.priority - b.priority);
1729
+
1730
+ if (masterDoc) {
1731
+ fs.writeFileSync(path.join(projectDir, "MASTER_SKILL.md"), masterDoc.content);
1732
+ console.log(` ${c("green", "✓")} MASTER_SKILL.md`);
1733
+ }
1734
+
1735
+ if (moduleDocs.length > 0) {
1736
+ const modulesDir = path.join(projectDir, "modules");
1737
+ mkdirp(modulesDir);
1738
+ for (const doc of moduleDocs) {
1739
+ const safeName = doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1740
+ const modDir = path.join(modulesDir, safeName);
1741
+ mkdirp(modDir);
1742
+ fs.writeFileSync(path.join(modDir, "SKILL.md"), doc.content);
1743
+ console.log(` ${c("green", "✓")} modules/${safeName}/SKILL.md`);
1747
1744
  }
1745
+ }
1748
1746
 
1749
- for (const doc of reportDocs) {
1750
- const fileName = doc.document_type.toUpperCase() + ".md";
1751
- fs.writeFileSync(path.join(resolved, fileName), doc.content);
1752
- }
1747
+ // ── Report & guide documents — write as DOCUMENT_TYPE.md at root ──
1748
+ const REPORT_FILENAMES = {
1749
+ api_registry: "API_REGISTRY.md",
1750
+ business_rules: "BUSINESS_RULES.md",
1751
+ data_models: "DATA_MODELS.md",
1752
+ dependencies: "DEPENDENCIES.md",
1753
+ env_config: "ENV_CONFIG.md",
1754
+ risk_report: "RISK_REPORT.md",
1755
+ glossary: "GLOSSARY.md",
1756
+ overview: "OVERVIEW.md",
1757
+ reproduction_guide: "REPRODUCTION_GUIDE.md",
1758
+ };
1753
1759
 
1754
- if (diagramDocs.length > 0) {
1755
- const diagramsDir = path.join(resolved, "diagrams");
1756
- mkdirp(diagramsDir);
1757
- for (const doc of diagramDocs) {
1758
- const safeName = doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1759
- fs.writeFileSync(path.join(diagramsDir, `${safeName}.mmd`), doc.content);
1760
- }
1760
+ for (const doc of [...reportDocs, ...guideDocs]) {
1761
+ const fileName = REPORT_FILENAMES[doc.document_type] || (doc.document_type.toUpperCase() + ".md");
1762
+ fs.writeFileSync(path.join(projectDir, fileName), doc.content);
1763
+ console.log(` ${c("green", "✓")} ${fileName}`);
1764
+ }
1765
+
1766
+ // ── Diagram documents ──
1767
+ if (diagramDocs.length > 0) {
1768
+ const diagramsDir = path.join(projectDir, "diagrams");
1769
+ mkdirp(diagramsDir);
1770
+ for (const doc of diagramDocs) {
1771
+ const safeName = doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1772
+ const ext = doc.document_type === "mermaid" ? "mmd" : "mmd";
1773
+ const diagramFile = `${safeName}.${ext}`;
1774
+ fs.writeFileSync(path.join(diagramsDir, diagramFile), doc.content);
1775
+ console.log(` ${c("green", "✓")} diagrams/${diagramFile}`);
1761
1776
  }
1777
+ }
1762
1778
 
1763
- console.log(` ${c("green", "✓")} Raw files saved to: ${c("bold", resolved)}\n`);
1779
+ // ── Reconstruct manifest.json ──
1780
+ const manifestSkills = [];
1781
+ if (masterDoc) {
1782
+ manifestSkills.push({ name: masterDoc.name, type: "master", file: "MASTER_SKILL.md" });
1764
1783
  }
1784
+ for (const doc of moduleDocs) {
1785
+ const safeName = doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1786
+ manifestSkills.push({ name: doc.name, type: "module", file: `modules/${safeName}/SKILL.md` });
1787
+ }
1788
+
1789
+ const manifestDiagrams = diagramDocs.map((doc) => {
1790
+ const safeName = doc.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1791
+ return { name: doc.name, file: `diagrams/${safeName}.mmd`, type: doc.document_type };
1792
+ });
1765
1793
 
1766
- console.log(c("green", `✓ "${project.name}" is ready. Restart your AI tool to activate the skills.\n`));
1767
- if (result.project?.console_url) {
1768
- console.log(` Console: ${c("dim", result.project.console_url)}\n`);
1794
+ const manifestReports = {};
1795
+ for (const doc of [...reportDocs, ...guideDocs]) {
1796
+ const fileName = REPORT_FILENAMES[doc.document_type] || (doc.document_type.toUpperCase() + ".md");
1797
+ manifestReports[doc.document_type] = fileName;
1798
+ }
1799
+
1800
+ const manifest = {
1801
+ project: project.name,
1802
+ scanned_at: project.last_scanned_at || new Date().toISOString(),
1803
+ downloaded_at: new Date().toISOString(),
1804
+ source: "valentia-skills-console",
1805
+ tech_stack: project.tech_stack || {},
1806
+ skills: manifestSkills,
1807
+ diagrams: manifestDiagrams,
1808
+ reports: manifestReports,
1809
+ statistics: {
1810
+ total_modules: moduleDocs.length,
1811
+ total_diagrams: diagramDocs.length,
1812
+ completeness_score: project.completeness_score,
1813
+ },
1814
+ };
1815
+ fs.writeFileSync(path.join(projectDir, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n");
1816
+ console.log(` ${c("green", "✓")} manifest.json`);
1817
+
1818
+ console.log(c("green", `\n✓ "${project.name}" downloaded — ${documents.length} file(s)\n`));
1819
+ console.log(` Folder: ${c("bold", projectDir)}`);
1820
+ if (project.console_url) {
1821
+ console.log(` Console: ${c("dim", project.console_url)}`);
1769
1822
  }
1823
+ console.log("");
1770
1824
  return;
1771
1825
 
1772
1826
  } else if (subcommand === "remove") {
@@ -1824,8 +1878,8 @@ Usage:
1824
1878
  npx ai-skills list List locally bundled skills
1825
1879
  npx ai-skills analyze Analyze last commit against active skills
1826
1880
  npx ai-skills upload-legacy-scan Upload a legacy codebase intelligence package
1827
- npx ai-skills legacy-projects add <name> Download project skills install into AI tools
1828
- npx ai-skills legacy-projects add <name> --path <dir> Also save raw files to a local directory
1881
+ npx ai-skills legacy-projects add <name> Download project → recreate intelligence folder locally
1882
+ npx ai-skills legacy-projects add <name> --path <dir> Save to a specific directory (default: cwd)
1829
1883
  npx ai-skills legacy-projects list List all legacy projects
1830
1884
  npx ai-skills legacy-projects status <name> Show project status and document counts
1831
1885
  npx ai-skills legacy-projects remove <name> Delete a project and all its documents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentia-ai-skills/framework",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "AI development skills framework centralized coding standards, security patterns, and SOPs for AI-assisted development. Works with Claude Code, Cursor, Copilot, Windsurf, and any AI coding tool.",
5
5
  "keywords": [
6
6
  "ai-skills",