openprompt-lang 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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +663 -0
  3. package/bin/cli.js +110 -0
  4. package/bin/lint.js +50 -0
  5. package/docs/COMMANDS.md +229 -0
  6. package/docs/COMMITS/INDEX.md +11 -0
  7. package/docs/COMMITS/v0.1.0-existing.md +31 -0
  8. package/docs/COMMITS/v0.1.0-inicial.md +50 -0
  9. package/docs/COMMITS/v0.1.0-readme.md +24 -0
  10. package/docs/COMMITS/v0.2.0-strict-db-templates.md +50 -0
  11. package/docs/COMMITS/v0.3.0-parser-fixes-vscode.md +67 -0
  12. package/docs/COMMITS/v0.3.0-versioning-component.md +44 -0
  13. package/docs/DEPENDENCIES.md +45 -0
  14. package/docs/FRAMEWORK.md +1741 -0
  15. package/docs/SYNTAX.md +359 -0
  16. package/docs/VERSIONING.md +150 -0
  17. package/docs/referencia-metodologia/Anexos Finales Documentos de Respaldo y Estandarizaci/303/263n.md" +90 -0
  18. package/docs/referencia-metodologia/Cotizaciones.md +84 -0
  19. package/docs/referencia-metodologia/Example.md +1 -0
  20. package/docs/referencia-metodologia/ExtractorInformacion.py +78 -0
  21. package/docs/referencia-metodologia/Fase - 1 .- Desarrollo de la Metodolog/303/255a.md" +67 -0
  22. package/docs/referencia-metodologia/Fase - 2 .- Levantamiento de requisitos generales y traduccion a la IA.md +64 -0
  23. package/docs/referencia-metodologia/Fase - 3 .- Prototipado visual con IA (Figma Maker o equivalentes).md +64 -0
  24. package/docs/referencia-metodologia/Fase - 4 .- Especificacion de requisitos e iteracion con el cliente.md +58 -0
  25. package/docs/referencia-metodologia/Fase - 5 .- Estructuracion y maquetado de funciones (Scaffolding).md +118 -0
  26. package/docs/referencia-metodologia/Fase - 6 .- Estructuracion del backlog y division de tareas.md +48 -0
  27. package/docs/referencia-metodologia/Fase - 7 .- Desarrollo activo, pruebas y control de versiones.md +98 -0
  28. package/docs/referencia-metodologia/Fase - 8 .- Entrega, capacitaci/303/263n y mantenimiento.md" +55 -0
  29. package/docs/referencia-metodologia/Figma prompt template.md +130 -0
  30. package/docs/referencia-metodologia/Framework de Desarrollo Asistido por IA.md +1741 -0
  31. package/docs/referencia-metodologia/Indice General.md +83 -0
  32. package/docs/referencia-metodologia/Prompt refactorizar o creacion desde cero.md +50 -0
  33. package/docs/referencia-metodologia/docs/CONVENCIONES_DB.md +410 -0
  34. package/docs/referencia-metodologia/docs/CONVENCIONES_DOCUMENTACION.md +209 -0
  35. package/docs/referencia-metodologia/docs/PROMPTS/INDEX.md +73 -0
  36. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/01-hook-supabase.md +79 -0
  37. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/02-componente-ui.md +82 -0
  38. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/03-pagina-feature.md +70 -0
  39. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/04-comando-tauri.md +56 -0
  40. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/05-store-zustand.md +74 -0
  41. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/06-servicio-supabase.md +74 -0
  42. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/07-formulario-validacion.md +63 -0
  43. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/08-hook-capacitor.md +65 -0
  44. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/09-refactor-division.md +51 -0
  45. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/10-scaffolding-inicial.md +79 -0
  46. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/11-supabase-crud-service.md +114 -0
  47. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/12-supabase-hook-usetable.md +143 -0
  48. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/13-tauri-command-rust.md +84 -0
  49. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/14-tauri-wrapper-typescript.md +92 -0
  50. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/15-documentar-tabla-db.md +50 -0
  51. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/16-diagrama-arquitectura.md +60 -0
  52. package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/17-documentar-api-rpc.md +56 -0
  53. package/docs/referencia-metodologia/docs/PROMPTS/STACK/ionic-capacitor.md +52 -0
  54. package/docs/referencia-metodologia/docs/PROMPTS/STACK/react-web-puro.md +46 -0
  55. package/docs/referencia-metodologia/docs/PROMPTS/STACK/tauri-desktop.md +53 -0
  56. package/package.json +56 -0
  57. package/schemas/prompt-lang.json +98 -0
  58. package/src/commands/component.js +326 -0
  59. package/src/commands/context.js +206 -0
  60. package/src/commands/figma.js +63 -0
  61. package/src/commands/init.js +373 -0
  62. package/src/commands/suggest.js +31 -0
  63. package/src/commands/validate.js +183 -0
  64. package/src/generators/figma-prompt.js +56 -0
  65. package/src/utils/ai.js +143 -0
  66. package/src/utils/annotations.js +510 -0
  67. package/src/utils/config.js +60 -0
  68. package/vscode-extension/README.md +31 -0
  69. package/vscode-extension/language-configuration.json +7 -0
  70. package/vscode-extension/package.json +62 -0
  71. package/vscode-extension/snippets/promptlang.json +105 -0
  72. package/vscode-extension/syntaxes/annotations.tmGrammar.json +39 -0
  73. package/vscode-extension/syntaxes/promptlang.tmGrammar.json +14 -0
@@ -0,0 +1,60 @@
1
+ import { readFileSync, existsSync } from "fs";
2
+ import { join } from "path";
3
+
4
+ const CONFIG_FILE = "prompt-lang.json";
5
+
6
+ export function loadConfig(dir = process.cwd()) {
7
+ const configPath = join(dir, CONFIG_FILE);
8
+ if (!existsSync(configPath)) {
9
+ return getDefaultConfig();
10
+ }
11
+ try {
12
+ const raw = readFileSync(configPath, "utf-8");
13
+ return { ...getDefaultConfig(), ...JSON.parse(raw) };
14
+ } catch {
15
+ console.warn("⚠️ Error leyendo prompt-lang.json. Usando defaults.");
16
+ return getDefaultConfig();
17
+ }
18
+ }
19
+
20
+ export function getDefaultConfig() {
21
+ return {
22
+ name: "mi-proyecto",
23
+ version: "0.1.0",
24
+ stack: {
25
+ base: ["react", "typescript", "vite", "tailwind"],
26
+ extensions: [],
27
+ },
28
+ profile: "senior",
29
+ pipeline: {
30
+ "pre-commit": ["lint", "typecheck"],
31
+ scripts: {},
32
+ },
33
+ annotations: {
34
+ enabled: true,
35
+ strict: true,
36
+ },
37
+ docs: {
38
+ commits: true,
39
+ logs: true,
40
+ backlog: true,
41
+ },
42
+ extractor: {
43
+ ignore: [".env", "*.local", "dist"],
44
+ output: "contexto.md",
45
+ },
46
+ };
47
+ }
48
+
49
+ export function detectStack(dir = process.cwd()) {
50
+ const has = (file) => existsSync(join(dir, file));
51
+ return {
52
+ react: has("package.json") && existsSync(join(dir, "src", "App.tsx")),
53
+ vite: has("vite.config.ts"),
54
+ tailwind: has("tailwind.config.ts") || has("tailwind.config.js"),
55
+ ionic: has("ionic.config.json"),
56
+ tauri: has("src-tauri"),
57
+ supabase: has("supabase") || has("supabase-config.ts"),
58
+ typescript: has("tsconfig.json"),
59
+ };
60
+ }
@@ -0,0 +1,31 @@
1
+ # openPrompt-Lang — VS Code Extension
2
+
3
+ Syntax highlighting, snippets y detección de anotaciones PromptLang en tiempo real.
4
+
5
+ ## Features
6
+
7
+ - **Syntax highlighting**: `@kind`, `@props`, `@contract`, `@use` y todos los tags PromptLang se resaltan en comentarios de TypeScript/JavaScript
8
+ - **Snippets**: prefijos `@kind-*` para insertar estructuras completas:
9
+ - `@kind-hook` → hook con `@contract`
10
+ - `@kind-component` → componente con `@props`
11
+ - `@kind-service` → servicio con `@contract` + `@platform`
12
+ - `@kind-page` → página con `@compose`
13
+ - `@kind-store` → store Zustand
14
+ - `@use-header` → declaración `@use()`
15
+ - `@props-ts` → props con sintaxis tipo TypeScript
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # Desde el código fuente
21
+ cd vscode-extension
22
+ npm install -g @vscode/vsce
23
+ vsce package
24
+ code --install-extension openprompt-lang-*.vsix
25
+ ```
26
+
27
+ O copia la carpeta `vscode-extension/` a `~/.vscode/extensions/`.
28
+
29
+ ## Usage
30
+
31
+ Escribe `@kind-` en cualquier archivo `.ts` o `.tsx` y selecciona un snippet del autocompletado. Los tags se resaltarán automáticamente en los comentarios.
@@ -0,0 +1,7 @@
1
+ {
2
+ "comments": {
3
+ "lineComment": "//",
4
+ "blockComment": ["/*", "*/"]
5
+ },
6
+ "brackets": [["{", "}"]]
7
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "openprompt-lang",
3
+ "displayName": "openPrompt-Lang",
4
+ "description": "Syntax highlighting, snippets y validación en vivo para anotaciones PromptLang",
5
+ "version": "0.3.0",
6
+ "publisher": "openprompt-lang",
7
+ "license": "MIT",
8
+ "engines": {
9
+ "vscode": "^1.85.0"
10
+ },
11
+ "categories": [
12
+ "Programming Languages",
13
+ "Snippets",
14
+ "Formatters"
15
+ ],
16
+ "keywords": [
17
+ "prompt-lang",
18
+ "openprompt",
19
+ "annotations",
20
+ "ai",
21
+ "react"
22
+ ],
23
+ "icon": "icon.png",
24
+ "contributes": {
25
+ "languages": [
26
+ {
27
+ "id": "promptlang",
28
+ "aliases": ["PromptLang", "promptlang"],
29
+ "configuration": "./language-configuration.json"
30
+ }
31
+ ],
32
+ "grammars": [
33
+ {
34
+ "language": "promptlang",
35
+ "scopeName": "source.promptlang",
36
+ "path": "./syntaxes/promptlang.tmGrammar.json",
37
+ "embeddedLanguages": {
38
+ "source.ts": "typescript",
39
+ "source.tsx": "typescriptreact"
40
+ }
41
+ },
42
+ {
43
+ "scopeName": "markup.promptlang.comments",
44
+ "path": "./syntaxes/annotations.tmGrammar.json",
45
+ "injectTo": ["source.ts", "source.tsx", "source.js", "source.jsx"],
46
+ "embeddedLanguages": {
47
+ "meta.annotation.promptlang": "promptlang"
48
+ }
49
+ }
50
+ ],
51
+ "snippets": [
52
+ {
53
+ "language": "typescript",
54
+ "path": "./snippets/promptlang.json"
55
+ },
56
+ {
57
+ "language": "typescriptreact",
58
+ "path": "./snippets/promptlang.json"
59
+ }
60
+ ]
61
+ }
62
+ }
@@ -0,0 +1,105 @@
1
+ {
2
+ "PromptLang: Add @kind hook": {
3
+ "prefix": "@kind-hook",
4
+ "body": [
5
+ "// @use(kind, contract, limit, deps)",
6
+ "// @kind(hook)",
7
+ "// @limit(lines: 60)",
8
+ "// @contract(in: ${1:input} -> out: ${2:output} @error: ${3:Error})",
9
+ "// @deps(@external: [${4:react}])",
10
+ "",
11
+ "export function use${5:Name}(${1:input}: ${6:string}) {",
12
+ " return ${2:output}",
13
+ "}"
14
+ ],
15
+ "description": "Add annotations for a custom hook"
16
+ },
17
+ "PromptLang: Add @kind component": {
18
+ "prefix": "@kind-component",
19
+ "body": [
20
+ "// @use(kind, props, state, limit, pattern)",
21
+ "// @kind(component)",
22
+ "// @props({ ${1:prop}: \"${2:string}\" })",
23
+ "// @state(idle${3:, loading, error})",
24
+ "// @limit(lines: 80)",
25
+ "// @pattern(composition)",
26
+ "",
27
+ "interface ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}Props {",
28
+ " ${1:prop}: ${2:string}",
29
+ "}",
30
+ "",
31
+ "export function ${TM_FILENAME_BASE}(${4:{ ${1:prop} }: ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}Props}) {",
32
+ " return <div>{${1:prop}}</div>",
33
+ "}"
34
+ ],
35
+ "description": "Add annotations for a UI component"
36
+ },
37
+ "PromptLang: Add @kind service": {
38
+ "prefix": "@kind-service",
39
+ "body": [
40
+ "// @use(kind, contract, limit, deps, platform)",
41
+ "// @kind(service)",
42
+ "// @limit(lines: 100)",
43
+ "// @contract(in: ${1:input} -> out: ${2:output} @error: ${3:Error})",
44
+ "// @deps(@external: [${4:supabase}])",
45
+ "// @platform(web)",
46
+ "",
47
+ "export async function ${1:fetchData}() {",
48
+ " // ...",
49
+ "}"
50
+ ],
51
+ "description": "Add annotations for a service"
52
+ },
53
+ "PromptLang: Add @kind page": {
54
+ "prefix": "@kind-page",
55
+ "body": [
56
+ "// @use(kind, compose, limit, state, deps)",
57
+ "// @kind(page)",
58
+ "// @compose(${1:ComponentA}, ${2:ComponentB})",
59
+ "// @state(loading, empty, error, success)",
60
+ "// @limit(lines: 150)",
61
+ "",
62
+ "export function ${TM_FILENAME_BASE}() {",
63
+ " return <div>${TM_FILENAME_BASE}</div>",
64
+ "}"
65
+ ],
66
+ "description": "Add annotations for a page"
67
+ },
68
+ "PromptLang: Add @kind store": {
69
+ "prefix": "@kind-store",
70
+ "body": [
71
+ "// @use(kind, limit, deps, scope, meta)",
72
+ "// @kind(store)",
73
+ "// @limit(lines: 60)",
74
+ "// @deps(@external: [zustand])",
75
+ "// @scope(module: ${1:app}, affects: [], breaking: false)",
76
+ "",
77
+ "import { create } from \"zustand\"",
78
+ "",
79
+ "interface ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}State {",
80
+ " ${2:value}: ${3:string}",
81
+ " set${2:/pascalcase}: (v: ${3:string}) => void",
82
+ "}",
83
+ "",
84
+ "export const use${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}Store = create<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}State>(set => ({",
85
+ " ${2:value}: \"\",",
86
+ " set${2:/pascalcase}: (${2:value}) => set({ ${2:value} }),",
87
+ "}))"
88
+ ],
89
+ "description": "Add annotations for a Zustand store"
90
+ },
91
+ "PromptLang: Add @use header": {
92
+ "prefix": "@use-header",
93
+ "body": [
94
+ "// @use(kind${1:, contract, props, state, limit, deps, compose, platform, scope})"
95
+ ],
96
+ "description": "Add @use declaration header"
97
+ },
98
+ "PromptLang: Add @props with TS syntax": {
99
+ "prefix": "@props-ts",
100
+ "body": [
101
+ "// @props({ ${1:propName}: \"${2:string}\"${3:, \"${4:optProp?}\": \"${5:number}\"} })"
102
+ ],
103
+ "description": "Add @props with TypeScript-like syntax"
104
+ }
105
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
+ "name": "PromptLang Annotations",
4
+ "scopeName": "markup.promptlang.comments",
5
+ "injectionSelector": "L:comment.line.double-slash -comment, L:comment.block -comment",
6
+ "patterns": [
7
+ {
8
+ "name": "meta.annotation.promptlang",
9
+ "match": "(@use|@kind|@contract|@props|@state|@limit|@compose|@deps|@platform|@scope|@test|@meta|@forbidden|@pattern|@error)(\\()",
10
+ "captures": {
11
+ "1": { "name": "entity.name.tag.promptlang" },
12
+ "2": { "name": "punctuation.definition.group.promptlang" }
13
+ }
14
+ },
15
+ {
16
+ "name": "meta.annotation.promptlang.arg",
17
+ "match": "(\\w+)(\\s*)(:)(\\s*)(\\[?[^\\],)]+\\]?)",
18
+ "captures": {
19
+ "1": { "name": "variable.parameter.promptlang" },
20
+ "3": { "name": "punctuation.separator.promptlang" },
21
+ "5": { "name": "string.unquoted.promptlang" }
22
+ }
23
+ },
24
+ {
25
+ "name": "meta.annotation.promptlang.separator",
26
+ "match": "(->)",
27
+ "captures": {
28
+ "1": { "name": "keyword.operator.arrow.promptlang" }
29
+ }
30
+ },
31
+ {
32
+ "name": "meta.annotation.promptlang.value",
33
+ "match": "((?:\\w+|\\.\\.\\.))",
34
+ "captures": {
35
+ "1": { "name": "support.type.promptlang" }
36
+ }
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
+ "name": "PromptLang",
4
+ "scopeName": "source.promptlang",
5
+ "patterns": [
6
+ {
7
+ "name": "meta.annotation.promptlang.bare",
8
+ "match": "@(\\w+)\\b",
9
+ "captures": {
10
+ "1": { "name": "entity.name.tag.promptlang" }
11
+ }
12
+ }
13
+ ]
14
+ }