graphicode-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
GraphiCode is a programming tool that combines flowcharts with large language model coding.
This init skill is responsible for initializing a GraphiCode-managed project by collecting project information, creating
graphig.json
, and setting up the required directory structure.
GraphiCode是一款将流程图与大语言模型编码相结合的编程工具。
这个初始化skill负责通过收集项目信息、创建
graphig.json
文件以及搭建所需的目录结构,来初始化一个由GraphiCode管理的项目。

Steps

步骤

0. Check if graphig.json already exists

0. 检查graphig.json是否已存在

sh
cat ./graphig.json
If
graphig.json
already exists, inform the user that the project is already initialized and exit immediately.
sh
cat ./graphig.json
如果
graphig.json
已存在,告知用户项目已完成初始化并立即退出。

1. Collect project information from the user

1. 向用户收集项目信息

Ask the user for the following fields (all at once):
  • appName — the application name
  • language — the programming language (e.g., TypeScript, Python)
  • devEnv — the development environment (e.g., Bun, Node.js, Deno)
  • runtimeEnv — the runtime environment (e.g., Bun, Node.js, Browser)
  • entryDir — the directory where the entry file is located (e.g.,
    src/entry
    )
  • flowDirs — directories for flow files (e.g.,
    { "src/flows": "default flow directory" }
    )
  • algorithmDirs — directories for algorithm files (e.g.,
    { "src/algorithms": "default algorithm directory" }
    )
  • stateDirs — directories for state files (e.g.,
    { "src/states": "default state directory" }
    )
  • typeDirs — directories for type files (e.g.,
    { "src/types": "default type directory" }
    )
If the user is unsure about any field, suggest reasonable defaults based on the project context.
一次性向用户收集以下字段信息:
  • appName — 应用名称
  • language — 编程语言(例如:TypeScript、Python)
  • devEnv — 开发环境(例如:Bun、Node.js、Deno)
  • runtimeEnv — 运行时环境(例如:Bun、Node.js、Browser)
  • entryDir — 入口文件所在目录(例如:
    src/entry
  • flowDirs — 流程图文件目录(例如:
    { "src/flows": "default flow directory" }
  • algorithmDirs — 算法文件目录(例如:
    { "src/algorithms": "default algorithm directory" }
  • stateDirs — 状态文件目录(例如:
    { "src/states": "default state directory" }
  • typeDirs — 类型文件目录(例如:
    { "src/types": "default type directory" }
如果用户对任何字段不确定,根据项目上下文提供合理的默认值建议。

2. Create graphig.json

2. 创建graphig.json

First, read
./references/<language>.md
(e.g.,
./references/TypeScript.md
) from this skill's directory to get the available devEnv/runtimeEnv options and their corresponding
projectConfig
,
mainFileName
,
testFileName
,
testCommand
values.
If the user's provided
language
,
devEnv
, or
runtimeEnv
does not match any entry in the reference file, prompt the user to revise their input before proceeding.
Then create
graphig.json
in the project root, combining the user's input from step 1 and the values looked up from the language reference file:
sh
echo '{
  "appName": "<appName>",
  "language": "<language>",
  "devEnv": "<devEnv>",
  "runtimeEnv": "<runtimeEnv>",
  "projectConfig": "<projectConfig>",
  "entryDir": "<entryDir>",
  "mainFileName": "<mainFileName>",
  "testFileName": "<testFileName>",
  "testCommand": "<testCommand>",
  "flowDirs": { "<dir1>": "<description1>" },
  "algorithmDirs": { "<dir1>": "<description1>" },
  "stateDirs": { "<dir1>": "<description1>" },
  "typeDirs": { "<dir1>": "<description1>" }
}' > ./graphig.json
首先读取该skill目录下的
./references/<language>.md
(例如
./references/TypeScript.md
)文件,获取可用的devEnv/runtimeEnv选项以及对应的
projectConfig
mainFileName
testFileName
testCommand
值。
如果用户提供的
language
devEnv
runtimeEnv
与参考文件中的任何条目不匹配,提示用户修改输入后再继续。
随后在项目根目录创建
graphig.json
,结合步骤1中用户输入的信息和从语言参考文件中查询到的值:
sh
echo '{
  "appName": "<appName>",
  "language": "<language>",
  "devEnv": "<devEnv>",
  "runtimeEnv": "<runtimeEnv>",
  "projectConfig": "<projectConfig>",
  "entryDir": "<entryDir>",
  "mainFileName": "<mainFileName>",
  "testFileName": "<testFileName>",
  "testCommand": "<testCommand>",
  "flowDirs": { "<dir1>": "<description1>" },
  "algorithmDirs": { "<dir1>": "<description1>" },
  "stateDirs": { "<dir1>": "<description1>" },
  "typeDirs": { "<dir1>": "<description1>" }
}' > ./graphig.json

3. Create directory structure

3. 创建目录结构

For each directory (key) in flowDirs/algorithmDirs/stateDirs/typeDirs:
  1. Create the directory (including parent directories if needed).
  2. Create an empty dir config file inside it:
sh
undefined
对于flowDirs/algorithmDirs/stateDirs/typeDirs中的每个目录(键):
  1. 创建该目录(如需则包含父目录)。
  2. 在其中创建一个空的目录配置文件:
sh
undefined

for each flowDir

for each flowDir

mkdir -p <flowDir> && echo '{}' > <flowDir>/flow.graphig.json
mkdir -p <flowDir> && echo '{}' > <flowDir>/flow.graphig.json

for each algorithmDir

for each algorithmDir

mkdir -p <algorithmDir> && echo '{}' > <algorithmDir>/algorithm.graphig.json
mkdir -p <algorithmDir> && echo '{}' > <algorithmDir>/algorithm.graphig.json

for each stateDir

for each stateDir

mkdir -p <stateDir> && echo '{}' > <stateDir>/state.graphig.json
mkdir -p <stateDir> && echo '{}' > <stateDir>/state.graphig.json

for each typeDir

for each typeDir

mkdir -p <typeDir> && echo '{}' > <typeDir>/type.graphig.json
undefined
mkdir -p <typeDir> && echo '{}' > <typeDir>/type.graphig.json
undefined

4. Copy utility files

4. 复制工具文件

Copy the language-specific utility files from this skill's assets directory to the project's
graphicode-utils/
directory:
sh
mkdir -p ./graphicode-utils
cp <this-skill-dir>/assets/<language>/* ./graphicode-utils/
Replace
<language>
with the value of the
language
field in
graphig.json
(e.g.,
TypeScript
).
将该skill的assets目录中特定语言的工具文件复制到项目的
graphicode-utils/
目录:
sh
mkdir -p ./graphicode-utils
cp <this-skill-dir>/assets/<language>/* ./graphicode-utils/
<language>
替换为
graphig.json
language
字段的值(例如
TypeScript
)。

5. Confirm to the user

5. 向用户确认

After all files and directories are created, print a summary of what was created and confirm the initialization is complete.
在所有文件和目录创建完成后,打印已创建内容的摘要,并确认初始化已完成。

Others

其他说明

Remember to respond in the language the user uses, and write files in English.
记得使用用户所使用的语言进行回复,并且以英文编写文件。