@jnyross/code-factory 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 snarktank
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Code Factory Template
2
+
3
+ A private-first template for running Ryan Carson-style "Ralph" autonomous loops with local CLI tooling and flat-rate subscriptions.
4
+
5
+ ## Zero-API Cost Principle
6
+ This template is built to avoid extra API token costs:
7
+ - Use local CLI agents (Claude Code CLI, Cursor Ultra agent mode, Antigravity, GLM coding plan, Minimax coding plan, ChatGPT Pro workflows).
8
+ - Do not add direct token-billed API calls in repository scripts.
9
+ - Keep all automation in repo-native shell scripts and CI.
10
+
11
+ ## Core Loop Files
12
+ - `ARCHITECTURE.yaml`: Machine-readable architecture contract.
13
+ - `AGENTS.md`: Shared autonomous loop policy.
14
+ - `prd.json`: Task queue for agents.
15
+ - `progress.txt`: Append-only execution journal.
16
+
17
+ ## Tool Rule Files
18
+ - `.cursorrules`: Cursor Ultra native behavior.
19
+ - `CLAUDE.md`: Claude Code CLI behavior.
20
+ - `.agent/rules/CodeFactory.md`: Antigravity/GLM/Minimax behavior.
21
+ - `prompt_template.txt`: ChatGPT Pro project-manager prompt.
22
+
23
+ ## Local Runner
24
+ `ralph.sh` is rewritten to use local CLI tools only.
25
+
26
+ Runner behavior:
27
+ 1. Reads next open task from `prd.json`.
28
+ 2. Invokes a local agent CLI for implementation (`codex` by default).
29
+ 3. Runs preflight checks:
30
+ - `npm run typecheck`
31
+ - `npm run lint`
32
+ - `npm test`
33
+ 4. Appends progress to `progress.txt`.
34
+ 5. Marks task done only when preflight passes.
35
+
36
+ Engine selection:
37
+ - Default: `codex` (`AGENT_ENGINE=codex`).
38
+ - Claude: `AGENT_ENGINE=claude`.
39
+ - OpenCode: `AGENT_ENGINE=opencode` (defaults to `minimax-coding-plan/MiniMax-M2.5`).
40
+ - Custom CLI: `AGENT_ENGINE=custom AGENT_CMD='<your command>'`.
41
+
42
+ Examples:
43
+ ```bash
44
+ ./ralph.sh --once
45
+ AGENT_ENGINE=claude ./ralph.sh --once
46
+ AGENT_ENGINE=opencode ./ralph.sh --once
47
+ OPENCODE_MODEL=minimax-coding-plan/MiniMax-M2.5 AGENT_ENGINE=opencode ./ralph.sh --once
48
+ AGENT_ENGINE=custom AGENT_CMD='your-cli --non-interactive -' ./ralph.sh --once
49
+ ```
50
+
51
+ Preflight directory selection:
52
+ - First choice: repository root.
53
+ - Fallback: `flowchart/` (included in this base template).
54
+ - Override with `PROJECT_DIR=/path/to/app`.
55
+
56
+ ## CI Safety Layer
57
+ - `.github/workflows/preflight.yml`
58
+ - Labels risky PRs as `high-risk` when touching paths like `db/`, `auth/`, or `infra/`.
59
+ - Runs typecheck/lint/tests in root or fallback `flowchart/`.
60
+ - `.github/workflows/auto-review.yml`
61
+ - Adds or updates a secondary agent-review comment on PRs.
62
+
63
+ ## New Project Bootstrap
64
+ Use the CLI to create a fresh repo from this template with clean git history.
65
+
66
+ Example:
67
+ ```bash
68
+ code-factory my-next-app ~/Projects
69
+ ```
70
+
71
+ Global install:
72
+ ```bash
73
+ npm install -g @jnyross/code-factory
74
+ ```
75
+
76
+ Compatibility alias:
77
+ - `new-project` points to the same CLI command as `code-factory`.
78
+
79
+ ## Suggested Working Loop
80
+ 1. Copy `prd.json.example` to `prd.json` (already present in this template).
81
+ 2. Add real tasks to `prd.json`.
82
+ 3. Run `./ralph.sh --once` for a single task cycle or `./ralph.sh` for looped operation.
83
+ 4. Review `progress.txt` after each run.
84
+ 5. Open PR and require preflight workflow success before merge.
85
+
86
+ ## Notes
87
+ - This template assumes a Node/TypeScript project with `typecheck`, `lint`, and `test` scripts.
88
+ - If you use different commands, update `ralph.sh`, `ARCHITECTURE.yaml`, and workflow files together.
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execFileSync } from "node:child_process";
4
+ import { existsSync, rmSync } from "node:fs";
5
+ import { resolve } from "node:path";
6
+ import process from "node:process";
7
+
8
+ const TEMPLATE_URL =
9
+ process.env.CODE_FACTORY_TEMPLATE_URL ??
10
+ "https://github.com/jnyross/code-factory-template.git";
11
+
12
+ function usage(exitCode = 0) {
13
+ console.log(`Usage:
14
+ code-factory <project-name> [destination-directory]
15
+ code-factory new <project-name> [destination-directory]
16
+
17
+ Examples:
18
+ code-factory my-app
19
+ code-factory "Youth Reg Response Platform" ~/Software_Projects
20
+
21
+ Environment:
22
+ CODE_FACTORY_TEMPLATE_URL Override template repository URL
23
+ `);
24
+ process.exit(exitCode);
25
+ }
26
+
27
+ function run(cmd, args) {
28
+ execFileSync(cmd, args, { stdio: "inherit" });
29
+ }
30
+
31
+ const rawArgs = process.argv.slice(2);
32
+
33
+ if (rawArgs.length === 0 || rawArgs.includes("-h") || rawArgs.includes("--help")) {
34
+ usage(0);
35
+ }
36
+
37
+ let args = rawArgs;
38
+ if (args[0] === "new") {
39
+ args = args.slice(1);
40
+ }
41
+
42
+ if (args.length < 1 || args.length > 2) {
43
+ usage(1);
44
+ }
45
+
46
+ const projectName = args[0];
47
+ const destinationDir = args[1] ?? process.cwd();
48
+ const targetPath = resolve(destinationDir, projectName);
49
+
50
+ if (existsSync(targetPath)) {
51
+ console.error(`Target already exists: ${targetPath}`);
52
+ process.exit(1);
53
+ }
54
+
55
+ try {
56
+ run("git", ["clone", TEMPLATE_URL, targetPath]);
57
+ rmSync(resolve(targetPath, ".git"), { recursive: true, force: true });
58
+ run("git", ["-C", targetPath, "init", "-q"]);
59
+ run("git", ["-C", targetPath, "add", "."]);
60
+ run("git", ["-C", targetPath, "commit", "-q", "-m", "Initial commit from Code Factory template"]);
61
+
62
+ console.log("Your new Code Factory project is ready!");
63
+ console.log(`Path: ${targetPath}`);
64
+ } catch (error) {
65
+ const message = error instanceof Error ? error.message : String(error);
66
+ console.error(`code-factory failed: ${message}`);
67
+ process.exit(1);
68
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@jnyross/code-factory",
3
+ "version": "1.0.0",
4
+ "description": "Bootstrap new repos from the Code Factory template.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/jnyross/code-factory-template.git"
10
+ },
11
+ "homepage": "https://github.com/jnyross/code-factory-template#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/jnyross/code-factory-template/issues"
14
+ },
15
+ "keywords": [
16
+ "code-factory",
17
+ "template",
18
+ "bootstrap",
19
+ "cli",
20
+ "ai",
21
+ "devops"
22
+ ],
23
+ "bin": {
24
+ "code-factory": "bin/code-factory.mjs",
25
+ "new-project": "bin/code-factory.mjs"
26
+ },
27
+ "files": [
28
+ "bin",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }