@valentia-ai-skills/framework 2.0.5 → 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 +18 -16
  2. package/bin/cli.js +159 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -65,14 +65,14 @@ npx ai-skills help # Show help
65
65
  #### Legacy Codebase Intelligence Scanner
66
66
 
67
67
  ```bash
68
- # Add / refresh a project by uploading a scan intelligence package
69
- npx ai-skills legacy-projects add --path ./my-project-intelligence/
68
+ # Upload a scan package to the Skills Console (creates or refreshes the project)
69
+ npx ai-skills upload-legacy-scan --path ./my-project-intelligence/
70
+ npx ai-skills upload-legacy-scan --path ./my-project-intelligence/ --dry-run # validate only
71
+ npx ai-skills upload-legacy-scan --path ./my-project-intelligence/ --token <token>
70
72
 
71
- # Validate the payload without uploading (dry run)
72
- npx ai-skills legacy-projects add --path ./my-project-intelligence/ --dry-run
73
-
74
- # Supply an explicit auth token instead of going through OTP
75
- npx ai-skills legacy-projects add --path ./my-project-intelligence/ --token <your-token>
73
+ # Download a project recreates exact intelligence folder structure (modules/, diagrams/, reports)
74
+ npx ai-skills legacy-projects add "My Project"
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
@@ -84,10 +84,7 @@ npx ai-skills legacy-projects status "My Project"
84
84
  npx ai-skills legacy-projects remove "My Project"
85
85
  ```
86
86
 
87
- > `upload-legacy-scan` is also available as a direct alias:
88
- > `npx ai-skills upload-legacy-scan --path ./my-project-intelligence/`
89
-
90
- The `--path` directory must contain a `manifest.json` file. See the [Legacy Scanner](#legacy-codebase-intelligence-scanner) section below for the required format.
87
+ The `--path` directory for `upload-legacy-scan` must contain a `manifest.json` file. See the [Legacy Scanner](#legacy-codebase-intelligence-scanner) section below for the required format.
91
88
 
92
89
  ### Environment Variables
93
90
 
@@ -289,10 +286,11 @@ The framework supports ingesting intelligence packages generated by legacy codeb
289
286
  ### How It Works
290
287
 
291
288
  1. **Scan** — A compatible scanner tool analyses an existing codebase and produces an intelligence folder
292
- 2. **Add** — `npx ai-skills legacy-projects add --path <folder>` uploads the package, creating the project if it doesn't exist or replacing its documents if it does
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
293
290
  3. **Review** — Tech leads review auto-generated skills, reports, and diagrams in the Skills Console, approving or flagging each document
294
- 4. **Promote** — Approved skills are promoted into the team's active toolkit and distributed on the next `npx ai-skills update`
295
- 5. **Rescan** — Re-running `add` on the same project name replaces all documents with the latest scan output
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
+ 6. **Rescan** — Re-running `upload-legacy-scan` on the same project name replaces all documents with the latest scan output
296
294
 
297
295
  ### Intelligence Package Format
298
296
 
@@ -347,8 +345,12 @@ Approved skills are promoted into the team's standard toolkit and distributed on
347
345
  ### Managing Projects from the CLI
348
346
 
349
347
  ```bash
350
- # Add a new project (or refresh an existing one)
351
- npx ai-skills legacy-projects add --path ./my-project-intelligence/
348
+ # Upload a scan package (add new project or replace existing)
349
+ npx ai-skills upload-legacy-scan --path ./my-project-intelligence/
350
+
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
352
354
 
353
355
  # List all projects with status, module count, and completeness score
354
356
  npx ai-skills legacy-projects list
package/bin/cli.js CHANGED
@@ -1665,8 +1665,162 @@ async function cmdLegacyProjects() {
1665
1665
  console.log(`\n Console: ${c("dim", p.console_url)}\n`);
1666
1666
 
1667
1667
  } else if (subcommand === "add") {
1668
- // Delegate to upload-legacy-scan argv flags (--path, --dry-run, --token) are preserved
1669
- await cmdUploadLegacyScan();
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
+
1680
+ const projectName = args[0];
1681
+ if (!projectName) {
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"));
1684
+ process.exit(1);
1685
+ }
1686
+
1687
+ // --path defaults to current working directory
1688
+ let outputBase = process.cwd();
1689
+ for (let i = 1; i < args.length; i++) {
1690
+ if (args[i] === "--path" && args[i + 1]) outputBase = args[++i];
1691
+ }
1692
+
1693
+ console.log(c("blue", `\n━━━ Download Legacy Project: ${projectName} ━━━\n`));
1694
+
1695
+ let result;
1696
+ try {
1697
+ result = await fetchJSONWithAuth(MANAGE_LEGACY_PROJECTS_URL, { action: "download", email, project_name: projectName }, null);
1698
+ } catch (err) {
1699
+ console.log(c("red", `✗ ${err.message}`));
1700
+ process.exit(1);
1701
+ }
1702
+
1703
+ const project = result.project;
1704
+ const documents = result.documents || [];
1705
+
1706
+ if (documents.length === 0) {
1707
+ console.log(c("yellow", `No documents found for "${projectName}".\n Check the project name with: npx ai-skills legacy-projects list\n`));
1708
+ return;
1709
+ }
1710
+
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");
1714
+ const diagramDocs = documents.filter((d) => d.category === "diagram");
1715
+
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`);
1744
+ }
1745
+ }
1746
+
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
+ };
1759
+
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}`);
1776
+ }
1777
+ }
1778
+
1779
+ // ── Reconstruct manifest.json ──
1780
+ const manifestSkills = [];
1781
+ if (masterDoc) {
1782
+ manifestSkills.push({ name: masterDoc.name, type: "master", file: "MASTER_SKILL.md" });
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
+ });
1793
+
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)}`);
1822
+ }
1823
+ console.log("");
1670
1824
  return;
1671
1825
 
1672
1826
  } else if (subcommand === "remove") {
@@ -1695,7 +1849,7 @@ async function cmdLegacyProjects() {
1695
1849
 
1696
1850
  } else {
1697
1851
  console.log(c("red", `Unknown subcommand: ${subcommand}`));
1698
- console.log(c("dim", "Usage: npx ai-skills legacy-projects add --path <dir> | list | status <name> | remove <name>\n"));
1852
+ console.log(c("dim", "Usage: npx ai-skills legacy-projects add <name> | list | status <name> | remove <name>\n"));
1699
1853
  process.exit(1);
1700
1854
  }
1701
1855
  }
@@ -1724,7 +1878,8 @@ Usage:
1724
1878
  npx ai-skills list List locally bundled skills
1725
1879
  npx ai-skills analyze Analyze last commit against active skills
1726
1880
  npx ai-skills upload-legacy-scan Upload a legacy codebase intelligence package
1727
- npx ai-skills legacy-projects add --path <dir> Upload a scan package and add / refresh the project
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)
1728
1883
  npx ai-skills legacy-projects list List all legacy projects
1729
1884
  npx ai-skills legacy-projects status <name> Show project status and document counts
1730
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.5",
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",