@prism-d1/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.
Files changed (85) hide show
  1. package/dist/bin/prism-cli.d.ts +3 -0
  2. package/dist/bin/prism-cli.d.ts.map +1 -0
  3. package/dist/bin/prism-cli.js +10 -0
  4. package/dist/bin/prism-cli.js.map +1 -0
  5. package/dist/src/commands/assessment/deploy-cdk.d.ts +22 -0
  6. package/dist/src/commands/assessment/deploy-cdk.d.ts.map +1 -0
  7. package/dist/src/commands/assessment/deploy-cdk.js +59 -0
  8. package/dist/src/commands/assessment/deploy-cdk.js.map +1 -0
  9. package/dist/src/commands/assessment/interview-agent.d.ts +71 -0
  10. package/dist/src/commands/assessment/interview-agent.d.ts.map +1 -0
  11. package/dist/src/commands/assessment/interview-agent.js +648 -0
  12. package/dist/src/commands/assessment/interview-agent.js.map +1 -0
  13. package/dist/src/commands/assessment/run.d.ts +20 -0
  14. package/dist/src/commands/assessment/run.d.ts.map +1 -0
  15. package/dist/src/commands/assessment/run.js +23 -0
  16. package/dist/src/commands/assessment/run.js.map +1 -0
  17. package/dist/src/commands/assessment/web.d.ts +15 -0
  18. package/dist/src/commands/assessment/web.d.ts.map +1 -0
  19. package/dist/src/commands/assessment/web.js +1393 -0
  20. package/dist/src/commands/assessment/web.js.map +1 -0
  21. package/dist/src/commands/bootstrapper/install-eval-harness.d.ts +15 -0
  22. package/dist/src/commands/bootstrapper/install-eval-harness.d.ts.map +1 -0
  23. package/dist/src/commands/bootstrapper/install-eval-harness.js +99 -0
  24. package/dist/src/commands/bootstrapper/install-eval-harness.js.map +1 -0
  25. package/dist/src/commands/bootstrapper/install-git-hooks.d.ts +15 -0
  26. package/dist/src/commands/bootstrapper/install-git-hooks.d.ts.map +1 -0
  27. package/dist/src/commands/bootstrapper/install-git-hooks.js +141 -0
  28. package/dist/src/commands/bootstrapper/install-git-hooks.js.map +1 -0
  29. package/dist/src/commands/bootstrapper/setup-github-oidc.d.ts +6 -0
  30. package/dist/src/commands/bootstrapper/setup-github-oidc.d.ts.map +1 -0
  31. package/dist/src/commands/bootstrapper/setup-github-oidc.js +157 -0
  32. package/dist/src/commands/bootstrapper/setup-github-oidc.js.map +1 -0
  33. package/dist/src/commands/securityagent/setup.d.ts +14 -0
  34. package/dist/src/commands/securityagent/setup.d.ts.map +1 -0
  35. package/dist/src/commands/securityagent/setup.js +113 -0
  36. package/dist/src/commands/securityagent/setup.js.map +1 -0
  37. package/dist/src/commands/workshop/deploy-infra.d.ts +13 -0
  38. package/dist/src/commands/workshop/deploy-infra.d.ts.map +1 -0
  39. package/dist/src/commands/workshop/deploy-infra.js +73 -0
  40. package/dist/src/commands/workshop/deploy-infra.js.map +1 -0
  41. package/dist/src/commands/workshop/generate-demo-data.d.ts +16 -0
  42. package/dist/src/commands/workshop/generate-demo-data.d.ts.map +1 -0
  43. package/dist/src/commands/workshop/generate-demo-data.js +362 -0
  44. package/dist/src/commands/workshop/generate-demo-data.js.map +1 -0
  45. package/dist/src/commands/workshop/perform-pen-test.d.ts +14 -0
  46. package/dist/src/commands/workshop/perform-pen-test.d.ts.map +1 -0
  47. package/dist/src/commands/workshop/perform-pen-test.js +301 -0
  48. package/dist/src/commands/workshop/perform-pen-test.js.map +1 -0
  49. package/dist/src/commands/workshop/run-agent.d.ts +20 -0
  50. package/dist/src/commands/workshop/run-agent.d.ts.map +1 -0
  51. package/dist/src/commands/workshop/run-agent.js +89 -0
  52. package/dist/src/commands/workshop/run-agent.js.map +1 -0
  53. package/dist/src/commands/workshop/verify-setup.d.ts +14 -0
  54. package/dist/src/commands/workshop/verify-setup.d.ts.map +1 -0
  55. package/dist/src/commands/workshop/verify-setup.js +493 -0
  56. package/dist/src/commands/workshop/verify-setup.js.map +1 -0
  57. package/dist/src/index.d.ts +13 -0
  58. package/dist/src/index.d.ts.map +1 -0
  59. package/dist/src/index.js +44 -0
  60. package/dist/src/index.js.map +1 -0
  61. package/dist/src/scanner/categories.d.ts +8 -0
  62. package/dist/src/scanner/categories.d.ts.map +1 -0
  63. package/dist/src/scanner/categories.js +322 -0
  64. package/dist/src/scanner/categories.js.map +1 -0
  65. package/dist/src/scanner/index.d.ts +16 -0
  66. package/dist/src/scanner/index.d.ts.map +1 -0
  67. package/dist/src/scanner/index.js +59 -0
  68. package/dist/src/scanner/index.js.map +1 -0
  69. package/dist/src/scanner/reporter.d.ts +3 -0
  70. package/dist/src/scanner/reporter.d.ts.map +1 -0
  71. package/dist/src/scanner/reporter.js +102 -0
  72. package/dist/src/scanner/reporter.js.map +1 -0
  73. package/dist/src/scanner/scoring.d.ts +7 -0
  74. package/dist/src/scanner/scoring.d.ts.map +1 -0
  75. package/dist/src/scanner/scoring.js +77 -0
  76. package/dist/src/scanner/scoring.js.map +1 -0
  77. package/dist/src/scanner/types.d.ts +41 -0
  78. package/dist/src/scanner/types.d.ts.map +1 -0
  79. package/dist/src/scanner/types.js +2 -0
  80. package/dist/src/scanner/types.js.map +1 -0
  81. package/dist/src/scanner/utils.d.ts +16 -0
  82. package/dist/src/scanner/utils.d.ts.map +1 -0
  83. package/dist/src/scanner/utils.js +54 -0
  84. package/dist/src/scanner/utils.js.map +1 -0
  85. package/package.json +39 -0
@@ -0,0 +1,77 @@
1
+ import { basename, resolve } from 'node:path';
2
+ const LEVEL_MAP = [
3
+ { threshold: 96, level: 'L5.0', label: 'Autonomous', description: 'Agents contributing to architecture. >20% autonomous deployments.' },
4
+ { threshold: 91, level: 'L4.5', label: 'Orchestrated+', description: 'Near-autonomous. Multi-agent governance mature.' },
5
+ { threshold: 81, level: 'L4.0', label: 'Orchestrated', description: 'Multi-agent governance. Autonomy tiering. AI FinOps.' },
6
+ { threshold: 71, level: 'L3.5', label: 'Integrated+', description: 'Strong integration with emerging orchestration patterns.' },
7
+ { threshold: 56, level: 'L3.0', label: 'Integrated', description: 'Eval gates in CI/CD. First agentic workflow. AI SRE practices.' },
8
+ { threshold: 41, level: 'L2.5', label: 'Structured+', description: 'Structured with emerging integration patterns.' },
9
+ { threshold: 26, level: 'L2.0', label: 'Structured', description: 'AI tooling standardized. Spec-driven dev. Acceptance rate tracked.' },
10
+ { threshold: 16, level: 'L1.5', label: 'Experimental+', description: 'Some AI tooling adoption, but not yet structured.' },
11
+ { threshold: 0, level: 'L1.0', label: 'Experimental', description: 'Ad hoc AI use. No metrics. No shared tooling.' },
12
+ ];
13
+ export function computeLevel(totalScore) {
14
+ for (const e of LEVEL_MAP) {
15
+ if (totalScore >= e.threshold)
16
+ return { level: e.level, label: e.label, description: e.description };
17
+ }
18
+ return LEVEL_MAP[LEVEL_MAP.length - 1];
19
+ }
20
+ export function identifyStrengths(categories) {
21
+ return categories
22
+ .filter(c => c.earnedPoints > 0)
23
+ .sort((a, b) => (b.earnedPoints / b.maxPoints) - (a.earnedPoints / a.maxPoints))
24
+ .slice(0, 3)
25
+ .map(c => `${c.category} (${c.earnedPoints}/${c.maxPoints})`);
26
+ }
27
+ export function identifyGaps(categories) {
28
+ return categories
29
+ .filter(c => c.earnedPoints < c.maxPoints)
30
+ .sort((a, b) => (b.maxPoints - b.earnedPoints) - (a.maxPoints - a.earnedPoints))
31
+ .slice(0, 3)
32
+ .map(c => {
33
+ const pct = Math.round((c.earnedPoints / c.maxPoints) * 100);
34
+ return c.earnedPoints === 0
35
+ ? `No ${c.category.toLowerCase()} signals detected (0/${c.maxPoints})`
36
+ : `Limited ${c.category.toLowerCase()} (${c.earnedPoints}/${c.maxPoints}, ${pct}%)`;
37
+ });
38
+ }
39
+ const RECS = {
40
+ 'AI Tool Config': 'Add a CLAUDE.md file with spec-first enforcement rules',
41
+ 'Spec-Driven Dev': 'Create a specs/ directory and adopt spec templates',
42
+ 'Commit Hygiene': 'Add AI-Origin and AI-Model trailers to commit conventions',
43
+ 'CI/CD Integration': 'Add AI evaluation steps to your CI pipeline',
44
+ 'Eval & Quality': 'Set up Bedrock Evaluation or promptfoo for automated eval',
45
+ 'Testing Maturity': 'Increase test coverage and add AI-specific test patterns',
46
+ 'AI Observability': 'Deploy the PRISM metrics pipeline (CDK in infra/)',
47
+ 'Governance': 'Configure Bedrock Guardrails and define autonomy tiers',
48
+ 'Agent Workflows': 'Define your first agentic workflow with Strands SDK',
49
+ 'Platform & Reuse': 'Create a shared prompt library for team reuse',
50
+ 'Documentation': 'Document AI development guidelines for the team',
51
+ 'Dependencies': 'Add AI SDKs (@anthropic-ai/sdk, @aws-sdk/client-bedrock-runtime)',
52
+ };
53
+ export function generateRecommendations(categories) {
54
+ return categories
55
+ .filter(c => c.earnedPoints < c.maxPoints)
56
+ .sort((a, b) => (b.maxPoints - b.earnedPoints) - (a.maxPoints - a.earnedPoints))
57
+ .slice(0, 3)
58
+ .map(c => RECS[c.category])
59
+ .filter(Boolean);
60
+ }
61
+ export function buildScanResult(repoPath, categories) {
62
+ const totalScore = categories.reduce((s, c) => s + c.earnedPoints, 0);
63
+ const maxScore = categories.reduce((s, c) => s + c.maxPoints, 0);
64
+ return {
65
+ repoPath: resolve(repoPath),
66
+ repoName: basename(resolve(repoPath)),
67
+ scanDate: new Date().toISOString().split('T')[0],
68
+ totalScore,
69
+ maxScore,
70
+ prismLevel: computeLevel(totalScore),
71
+ categories,
72
+ strengths: identifyStrengths(categories),
73
+ gaps: identifyGaps(categories),
74
+ recommendations: generateRecommendations(categories),
75
+ };
76
+ }
77
+ //# sourceMappingURL=scoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../../src/scanner/scoring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG9C,MAAM,SAAS,GAA+E;IAC5F,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,mEAAmE,EAAE;IACvI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EA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,EAAE,CAAC,CAAC,CAAC;IACjE,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC;QAC3B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChD,UAAU;QACV,QAAQ;QACR,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;QACpC,UAAU;QACV,SAAS,EAAE,iBAAiB,CAAC,UAAU,CAAC;QACxC,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;QAC9B,eAAe,EAAE,uBAAuB,CAAC,UAAU,CAAC;KACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ /** Evidence collected by a single check within a scanner category. */
2
+ export interface Evidence {
3
+ signal: string;
4
+ found: boolean;
5
+ points: number;
6
+ detail: string;
7
+ }
8
+ /** Result of scanning one category. */
9
+ export interface CategoryScore {
10
+ category: string;
11
+ maxPoints: number;
12
+ earnedPoints: number;
13
+ evidence: Evidence[];
14
+ }
15
+ /** PRISM level info derived from the total score. */
16
+ export interface PRISMLevelInfo {
17
+ level: string;
18
+ label: string;
19
+ description: string;
20
+ }
21
+ /** Full scan result for a repository. */
22
+ export interface ScanResult {
23
+ repoPath: string;
24
+ repoName: string;
25
+ scanDate: string;
26
+ totalScore: number;
27
+ maxScore: number;
28
+ prismLevel: PRISMLevelInfo;
29
+ categories: CategoryScore[];
30
+ strengths: string[];
31
+ gaps: string[];
32
+ recommendations: string[];
33
+ }
34
+ /** Configuration passed to each scanner. */
35
+ export interface ScanConfig {
36
+ repoPath: string;
37
+ verbose: boolean;
38
+ commitDepth: number;
39
+ }
40
+ export type OutputFormat = 'console' | 'json' | 'markdown';
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/scanner/types.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;IAC3B,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/scanner/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /** Glob files in a repo, always ignoring common dirs. */
2
+ export declare function findFiles(repoPath: string, patterns: string | string[], extraIgnore?: string[]): Promise<string[]>;
3
+ /** Read file contents, returning empty string on failure. */
4
+ export declare function readSafe(repoPath: string, file: string): string;
5
+ /** Build a content cache for up to `limit` files. */
6
+ export declare function buildContentCache(repoPath: string, patterns: string | string[], limit?: number): Promise<Map<string, string>>;
7
+ /** Check if any pattern matches any value in a content cache. Returns [matched file, matched pattern source] or null. */
8
+ export declare function searchCache(cache: Map<string, string>, patterns: RegExp[]): {
9
+ file: string;
10
+ pattern: string;
11
+ } | null;
12
+ /** Check if a path exists and is a directory. */
13
+ export declare function dirExists(repoPath: string, subPath: string): boolean;
14
+ /** Check if a file exists. */
15
+ export declare function fileExists(repoPath: string, subPath: string): boolean;
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/scanner/utils.ts"],"names":[],"mappings":"AAMA,yDAAyD;AACzD,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,WAAW,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ5H;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,qDAAqD;AACrD,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAQhI;AAED,yHAAyH;AACzH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOpH;AAED,iDAAiD;AACjD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpE;AAED,8BAA8B;AAC9B,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAErE"}
@@ -0,0 +1,54 @@
1
+ import { glob } from 'glob';
2
+ import { readFileSync, existsSync, statSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ const IGNORE = ['node_modules/**', 'dist/**', '.git/**', 'package-lock.json', 'yarn.lock', 'vendor/**'];
5
+ /** Glob files in a repo, always ignoring common dirs. */
6
+ export async function findFiles(repoPath, patterns, extraIgnore = []) {
7
+ const pats = Array.isArray(patterns) ? patterns : [patterns];
8
+ const results = new Set();
9
+ for (const p of pats) {
10
+ const matches = await glob(p, { cwd: repoPath, dot: true, ignore: [...IGNORE, ...extraIgnore] }).catch(() => []);
11
+ matches.forEach((m) => results.add(m));
12
+ }
13
+ return [...results];
14
+ }
15
+ /** Read file contents, returning empty string on failure. */
16
+ export function readSafe(repoPath, file) {
17
+ try {
18
+ return readFileSync(join(repoPath, file), 'utf-8');
19
+ }
20
+ catch {
21
+ return '';
22
+ }
23
+ }
24
+ /** Build a content cache for up to `limit` files. */
25
+ export async function buildContentCache(repoPath, patterns, limit = 200) {
26
+ const files = await findFiles(repoPath, patterns);
27
+ const cache = new Map();
28
+ for (const f of files.slice(0, limit)) {
29
+ const content = readSafe(repoPath, f);
30
+ if (content)
31
+ cache.set(f, content);
32
+ }
33
+ return cache;
34
+ }
35
+ /** Check if any pattern matches any value in a content cache. Returns [matched file, matched pattern source] or null. */
36
+ export function searchCache(cache, patterns) {
37
+ for (const [file, content] of cache) {
38
+ for (const pat of patterns) {
39
+ if (pat.test(content))
40
+ return { file, pattern: pat.source };
41
+ }
42
+ }
43
+ return null;
44
+ }
45
+ /** Check if a path exists and is a directory. */
46
+ export function dirExists(repoPath, subPath) {
47
+ const full = join(repoPath, subPath);
48
+ return existsSync(full) && statSync(full).isDirectory();
49
+ }
50
+ /** Check if a file exists. */
51
+ export function fileExists(repoPath, subPath) {
52
+ return existsSync(join(repoPath, subPath));
53
+ }
54
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/scanner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,MAAM,GAAG,CAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AAExG,yDAAyD;AACzD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,QAA2B,EAAE,cAAwB,EAAE;IACvG,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACjH,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CA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,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAe;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,OAAe;IAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@prism-d1/cli",
3
+ "version": "1.0.0",
4
+ "description": "PRISM D1 Velocity CLI — AI development lifecycle assessment tool",
5
+ "author": "andklee",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/aws-samples/sample-prism-d1-velocity"
10
+ },
11
+ "type": "module",
12
+ "bin": {
13
+ "prism-cli": "./dist/bin/prism-cli.js"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "npx tsc",
23
+ "prepublishOnly": "npm run build",
24
+ "start": "tsx bin/prism-cli.ts",
25
+ "dev": "tsx bin/prism-cli.ts"
26
+ },
27
+ "dependencies": {
28
+ "@aws-sdk/client-bedrock-runtime": "^3.700.0",
29
+ "chalk": "^4.1.2",
30
+ "commander": "^12.1.0",
31
+ "glob": "^13.0.6",
32
+ "simple-git": "^3.36.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.14.0",
36
+ "tsx": "^4.16.0",
37
+ "typescript": "^5.5.0"
38
+ }
39
+ }