unifying with updated naming convention
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 29 May 2026 16:01:35 +0000 (16:01 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 29 May 2026 16:01:35 +0000 (16:01 +0000)
administrator/tool/new-project [new file with mode: 0755]
developer/authored/ExampleGreet/Greeter.lib.c [deleted file]
developer/authored/ExampleGreet/Math.lib.c [deleted file]
developer/authored/ExampleGreet/hello.CLI.c [deleted file]
developer/authored/example-greet/Greeter.lib.c [new file with mode: 0644]
developer/authored/example-greet/Math.lib.c [new file with mode: 0644]
developer/authored/example-greet/hello.CLI.c [new file with mode: 0644]

diff --git a/administrator/tool/new-project b/administrator/tool/new-project
new file mode 100755 (executable)
index 0000000..58d49e3
--- /dev/null
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+# -*- mode: python; coding: utf-8; python-indent-offset: 2; indent-tabs-mode: nil -*-
+
+import sys ,os ,subprocess
+from pathlib import Path
+
+def get_Z_date() -> str:
+  try:
+    res = subprocess.run(["Z" ,"format-%year-%month-%day"] ,capture_output=True ,text=True ,check=True)
+    return res.stdout.strip()
+  except Exception:
+    return "1970-01-01"
+
+def work(project_name: str ,remotes: list[str]) -> int:
+  repo_home = os.environ.get("REPO_HOME")
+  if not repo_home:
+    print("Error: REPO_HOME is not set. A person must run this from within a sourced role environment." ,file=sys.stderr)
+    return 1
+
+  repo_path = Path(repo_home).resolve()
+  
+  dest_path = Path(project_name)
+  if not dest_path.is_absolute():
+    dest_path = (repo_path.parent / project_name).resolve()
+
+  if dest_path.exists():
+    print(f"Error: Destination {dest_path} already exists." ,file=sys.stderr)
+    return 1
+
+  print(f"Creating new project at: {dest_path}")
+  dest_path.mkdir(parents=True)
+  
+  archive_cmd = "git archive HEAD | tar -x -C " + str(dest_path)
+  res = subprocess.run(archive_cmd ,shell=True ,cwd=str(repo_path))
+  if res.returncode != 0:
+    print("Error extracting archive." ,file=sys.stderr)
+    return 1
+
+  opus_src = dest_path / "0pus_Harmony"
+  opus_dst = dest_path / f"0pus_{dest_path.name}"
+  if opus_src.exists():
+    opus_src.rename(opus_dst)
+
+  version_file = dest_path / "shared" / "tool" / "version"
+  date_str = get_Z_date()
+  version_line = f"echo \"{dest_path.name} v0.1 {date_str}\"\n"
+  
+  if version_file.exists():
+    with open(version_file ,"a" ,encoding="utf-8") as vf:
+      vf.write(version_line)
+  else:
+    with open(version_file ,"w" ,encoding="utf-8") as vf:
+      vf.write(version_line)
+
+  print("Initializing git repository...")
+  subprocess.run(["git" ,"init" ,"-b" ,"core-developer_branch"] ,cwd=str(dest_path) ,check=True)
+  subprocess.run(["git" ,"add" ,"."] ,cwd=str(dest_path) ,check=True)
+  subprocess.run(["git" ,"commit" ,"-m" ,f"Initial commit of {dest_path.name} from Harmony skeleton"] ,cwd=str(dest_path) ,check=True)
+
+  for idx ,remote_url in enumerate(remotes):
+    remote_name = f"remote_{idx}"
+    if "github.com" in remote_url: 
+      remote_name = "github"
+    elif "RT" in remote_url: 
+      remote_name = "RT"
+    elif idx == 0:
+      remote_name = "origin"
+    
+    print(f"Adding remote '{remote_name}': {remote_url}")
+    subprocess.run(["git" ,"remote" ,"add" ,remote_name ,remote_url] ,cwd=str(dest_path) ,check=True)
+
+  print(f"Project '{dest_path.name}' successfully created.")
+  return 0
+
+def CLI(argv=None) -> int:
+  if argv is None:
+    argv = sys.argv[1:]
+
+  if not argv or "-h" in argv or "--help" in argv:
+    print("Usage: new-project <name> [-remote <url>]...")
+    return 0
+
+  project_name = None
+  remotes = []
+  
+  idx = 0
+  while idx < len(argv):
+    arg = argv[idx]
+    if arg == "-remote":
+      if idx + 1 < len(argv):
+        remotes.append(argv[idx+1])
+        idx += 1
+      else:
+        print("Error: -remote requires a URL." ,file=sys.stderr)
+        return 1
+    elif project_name is None:
+      project_name = arg
+    else:
+      print(f"Error: unexpected argument '{arg}'" ,file=sys.stderr)
+      return 1
+    idx += 1
+
+  if not project_name:
+    print("Error: project name is required." ,file=sys.stderr)
+    return 1
+
+  return work(project_name ,remotes)
+
+if __name__ == "__main__":
+  sys.exit(CLI())
diff --git a/developer/authored/ExampleGreet/Greeter.lib.c b/developer/authored/ExampleGreet/Greeter.lib.c
deleted file mode 100644 (file)
index 1d23879..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef ExampleGreet·Greeter·ONCE
-#define ExampleGreet·Greeter·ONCE
-
-#include "Math.lib.c"
-
-void ExampleGreet·Greeter·hello_loop(int count);
-
-#ifdef ExampleGreet·Greeter
-  #include <stdio.h>
-
-  void ExampleGreet·Greeter·hello_loop(int count){ 
-    for(int TM = 0; TM < count; ++TM){
-      int current_count = ExampleGreet·Math·add(TM ,1);
-      printf("Hello iteration: %d\n" ,current_count);
-    }
-  }
-
-#endif // ExampleGreet·Greeter
-
-#endif // ExampleGreet·Greeter·ONCE
diff --git a/developer/authored/ExampleGreet/Math.lib.c b/developer/authored/ExampleGreet/Math.lib.c
deleted file mode 100644 (file)
index 6f1880e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ExampleGreet·Math·ONCE
-#define ExampleGreet·Math·ONCE
-
-int ExampleGreet·Math·add(int a ,int b);
-
-#ifdef ExampleGreet·Math
-  int ExampleGreet·Math·add(int a ,int b){
-    return a + b;
-  }
-#endif // ExampleGreet·Math
-
-#endif // ExampleGreet·Math·ONCE
diff --git a/developer/authored/ExampleGreet/hello.CLI.c b/developer/authored/ExampleGreet/hello.CLI.c
deleted file mode 100644 (file)
index 684e2a7..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "Math.lib.c"
-#include "Greeter.lib.c"
-
-void CLI(void){ 
-  int base_count = ExampleGreet·Math·add(1 ,2);
-  printf("Calculated base loop count: %d\n" ,base_count);
-  ExampleGreet·Greeter·hello_loop(base_count);
-}
-
-int main(int argc ,char **argv){ 
-  (void)argc;
-  (void)argv;
-  
-  CLI();
-  
-  return EXIT_SUCCESS;
-}
diff --git a/developer/authored/example-greet/Greeter.lib.c b/developer/authored/example-greet/Greeter.lib.c
new file mode 100644 (file)
index 0000000..1d23879
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef ExampleGreet·Greeter·ONCE
+#define ExampleGreet·Greeter·ONCE
+
+#include "Math.lib.c"
+
+void ExampleGreet·Greeter·hello_loop(int count);
+
+#ifdef ExampleGreet·Greeter
+  #include <stdio.h>
+
+  void ExampleGreet·Greeter·hello_loop(int count){ 
+    for(int TM = 0; TM < count; ++TM){
+      int current_count = ExampleGreet·Math·add(TM ,1);
+      printf("Hello iteration: %d\n" ,current_count);
+    }
+  }
+
+#endif // ExampleGreet·Greeter
+
+#endif // ExampleGreet·Greeter·ONCE
diff --git a/developer/authored/example-greet/Math.lib.c b/developer/authored/example-greet/Math.lib.c
new file mode 100644 (file)
index 0000000..6f1880e
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef ExampleGreet·Math·ONCE
+#define ExampleGreet·Math·ONCE
+
+int ExampleGreet·Math·add(int a ,int b);
+
+#ifdef ExampleGreet·Math
+  int ExampleGreet·Math·add(int a ,int b){
+    return a + b;
+  }
+#endif // ExampleGreet·Math
+
+#endif // ExampleGreet·Math·ONCE
diff --git a/developer/authored/example-greet/hello.CLI.c b/developer/authored/example-greet/hello.CLI.c
new file mode 100644 (file)
index 0000000..684e2a7
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "Math.lib.c"
+#include "Greeter.lib.c"
+
+void CLI(void){ 
+  int base_count = ExampleGreet·Math·add(1 ,2);
+  printf("Calculated base loop count: %d\n" ,base_count);
+  ExampleGreet·Greeter·hello_loop(base_count);
+}
+
+int main(int argc ,char **argv){ 
+  (void)argc;
+  (void)argv;
+  
+  CLI();
+  
+  return EXIT_SUCCESS;
+}